#Node Client

1 messages · Page 1 of 1 (latest)

manic ferry
#

Hello @novel bough , can you please try again in this format?

client.permission.check({
    metadata: {
        depth: 3
    },
    tenantId: tenantId,
    entity: {
        type: "test",
        id: objectId
    },
    permission: relation,
    subject: {
        type: "user",
        id: userId
    }
}
novel bough
#

@manic ferry got the same error with that code

#

Granted, it was functionally my exact code, so I kinda expected that

#

Was there some kind of breaking change surrounding the node client and the GRPC API that I'm not aware of?

manic ferry
#

@novel bough , could you please write me the version of Permify Node that you are using and the version of Permify?

novel bough
#

Yup, one sec

#

I'm using ghcr.io/permify/permify:v0.4.7-3e428c2 and @permify/permify-node: ^0.3.6 - those should be the latest versions of both as of last night

manic ferry
#

@novel bough , Could you please try Permify version 0.4.6? Releases that appear in the format of v0.4.x-y are versions we test before the official release.

novel bough
#

@manic ferry installed ghcr.io/permify/permify:v0.4.6 and am getting the same error

manic ferry
#

@novel bough , I've tried with the same versions again on my end and I didn't receive such an issue. Can you try this check query with Postman or an alternative tool?

{
    "metadata": {
        "depth": 3
    },
    "entity": {
        "type": "test",
        "id": {{object_id}}
    },
    "permission": {{relation}},
    "subject": {
        "type": "user",
        "id": {{user_id}}
    }
}
acoustic yoke
#

I got the same issue
npm package version: 0.3.6
permify version: 0.4.7

#

The error is coming with gRPC
When I try through HTTP and Postman it works correctly

#
{
  "path": "/base.v1.Permission/Check",
  "code": 3,
  "details": "invalid PermissionCheckRequest.Metadata: embedded message failed validation | caused by: invalid PermissionCheckRequestMetadata.Depth: value must be greater than or equal to 3"
}
manic ferry
#

Hello @acoustic yoke , I am trying it out specifically for Grpc. I'll get back to you.

manic ferry
#
client.permission.check({
    tenantId: "t1",
    metadata: {
        depth: 3
    },
    entity: {
        type: "document",
        id: "1"
    },
    permission: "view",
    subject: {
        type: "user",
        id: "3"
    }
}).then((response) => {
    expect(response.can).toBe(CheckResult.RESULT_DENIED)
    done();
})

When I try it this way, I'm not getting any errors. Am I missing something? @acoustic yoke

acoustic yoke
#

Maybe I am, but I have the exact same code as you and it doesn't work
This is my code

this.permifyGrpcClient.permission
      .check({
        tenantId: 't1', //appConfig.permifyConfig.tenantId, // by default there will be only one tenant id
        metadata: {
          // snapToken: '',
          // schemaVersion: '',
          depth: 100,
        },
        entity: {
          type: 'section',
          id: '888888',
        },
        subject: {
          type: 'user',
          id: '111',
        },
        permission: 'edit',
      })
      .then((response) => {
        this.logger.info('Successfully checked authorization');
        return { allowed: response.can === PermissionCheckResponse_Result.RESULT_ALLOWED, failure: false };
      })
      .catch((error) => {
        this.metricsStore.inc(MetricNames.PERMIFY_CHECK_FAILURE);
        this.logger.error(
          {
            error,
            data: { resource_type, resource_id, subject_type, subject_id, action },
          },
          'Failed checking authorization',
        );
        return { allowed: false, failure: true };
      });
#

Every request is caught in the catch block and produce the following log:

{"path":"/base.v1.Permission/Check","code":3,"details":"invalid PermissionCheckRequest.Metadata: embedded message failed validation | caused by: invalid PermissionCheckRequestMetadata.Depth: value must be greater than or equal to 3"}
manic ferry
#

Hello @acoustic yoke , we've released Permify node 0.3.7, you can test this again for Permify v0.4.7. In our own tests, as long as 'depth' was given, we did not encounter such a problem. Could you try it again?

acoustic yoke
#

Yep with version 0.3.7 it works

#

Thanks