m

    Matthew Ebeweber

    2 weeks ago
    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.
    Perhaps some package version mismatch issue
    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)

    2 weeks ago
    Hey that's unexpected - let me look into this. What version of Cerbos and the adapter are you running?
    Also which version of the JS SDk are you using?
    m

    Matthew Ebeweber

    2 weeks ago
    "@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
    & using
    <http://ghcr.io/cerbos/cerbos:latest|ghcr.io/cerbos/cerbos:latest>
    Alex Olivier (Cerbos)

    Alex Olivier (Cerbos)

    2 weeks ago
    @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

    2 weeks ago
    I'm using the
    grpc
    in the code, I just uninstalled
    cerbos
    and the output is the same
    Alex Olivier (Cerbos)

    Alex Olivier (Cerbos)

    2 weeks ago
    hmm, could you share the response from the
    planResources
    call?
    we can move to DM if you don’t want to share it here
    m

    Matthew Ebeweber

    2 weeks ago
    Sounds good -- I'll ping you there
    Alex Olivier (Cerbos)

    Alex Olivier (Cerbos)

    2 weeks ago
    Just in case anyone else is reading this, this issue has been fixed in
    @cerbos/orm-prisma@0.1.2