Skip to content

create is incorrectly rejecting because of mishandled the rule case of id field and the connect semantics #627

@nitaicharan

Description

@nitaicharan

Description and expected behavior
When the policy withPolicy is set with the relation id filed, following error happened:

  @@allow('all', auth().id == tenant_id)
}

Screenshots

{
 "data": {
  ...
  "tenant": {
   "connect": {
    "id": "52262a1c-23d2-40ed-9e9f-ddb76a623e1a"
   }
  }
 }
}
[Nest] 8986  - 08/13/2023, 9:50:50 AM   ERROR [ExceptionsHandler] denied by policy: equipment entities failed 'create' check
Error calling enhanced Prisma method `create`: denied by policy: equipment entities failed 'create' check

Environment (please complete the following information):

  • ZenStack version: 1.0.0-beta.16
  • Prisma version: 5.0.0
  • Database type: Postgresql

Additional context
I'm using a Nestjs application.

@ymc9 Helped me in Discord:

I believe it's a regression since beta.15 release.
The "create" is incorrectly rejected because the rule mishandled the case of tenent_id field and the "connect" semantics.
...
the policy engine is supposed to treat a relation and the corresponding foreign key in the same way
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions