Title
#help
m

Matthew Ebeweber

09/06/2022, 10:03 PM
I'm attempting to use the
queryPlanToPrisma
logic to convert a cerbos response to a prisma query and am running into some trouble. Auditing the call, the
planResources
call is returning something formed from --
{
  "kind": "KIND_CONDITIONAL",
  "condition": {
    "expression": {
      "operator": "eq",
      "operands": [
        {
          "value": "qid::tenant:foo"
        },
        {
          "variable": "request.resource.attr.tenantQid"
        }
      ]
    }
  }
}
but then when I pass the result into
queryPlanToPrisma
with a pretty simple mapping
{ 'request.resource.attr.tenantQid': 'tenantQid'}
, I get filtering conditions that are
{ undefined: { equals: "undefined" } }
. I haven't gone too deep into the logic or tried other conditions, but was curious if I was doing something obviously wrong.
10:03 PM
Perhaps some package version mismatch issue
10:19 PM
If I mock the
planResources
call and play with the shape of the response I can get it to behave how I would expect. For example, this..
condition: {
            operator: "eq",
            operands: [
              {
                name: "request.resource.attr.tenantQid",
              },
              {
                value: "qid::tenant:foo",
              }
            ]
          },
does give me this..
Object {
  "tenantQid": Object {
    "equals": "qid::tenant:foo",
  },
}
Alex Olivier (Cerbos)

Alex Olivier (Cerbos)

09/07/2022, 6:26 AM
Hey that's unexpected - let me look into this. What version of Cerbos and the adapter are you running?
12:34 PM
Also which version of the JS SDk are you using?
m

Matthew Ebeweber

09/07/2022, 2:15 PM
"@cerbos/grpc": "^0.7.0",
"@cerbos/orm-prisma": "^0.1.1",
"cerbos": "^0.4.0",
Really appreciate your help here 🙂 let me know if I can provide you with anything else
2:15 PM
& using
<http://ghcr.io/cerbos/cerbos:latest|ghcr.io/cerbos/cerbos:latest>
Alex Olivier (Cerbos)

Alex Olivier (Cerbos)

09/07/2022, 2:17 PM
@cerbos/grpc
is the correct SDK, the
cerbos
one is deprecated now. which are you using in your code? this is likely the culrpit
m

Matthew Ebeweber

09/07/2022, 2:20 PM
I'm using the
grpc
in the code, I just uninstalled
cerbos
and the output is the same
Alex Olivier (Cerbos)

Alex Olivier (Cerbos)

09/07/2022, 2:21 PM
hmm, could you share the response from the
planResources
call?
2:22 PM
we can move to DM if you don’t want to share it here
m

Matthew Ebeweber

09/07/2022, 2:24 PM
Sounds good -- I'll ping you there
Alex Olivier (Cerbos)

Alex Olivier (Cerbos)

09/07/2022, 2:53 PM
Just in case anyone else is reading this, this issue has been fixed in
@cerbos/orm-prisma@0.1.2