Skip to content

Errors thrown when using @default together with auth() are normal error objects #1596

@nilswinking

Description

@nilswinking

Description and expected behavior
When using @default together with auth(), i.e. @default(auth().id) and no user context is set when making a create query a normal error is thrown instead of an PrismaClientKnownRequestError like it would be if the access policies are violated.
Further more this error seems to be thrown before those access policies are checked at all.

The line where is error is thrown:

throw new Error(`Evaluating default value of field \`${fieldInfo.name}\` requires a user context`);

Because a normal error is thrown instead of a specific one error handling is made difficult because every error needs to be caught instead of filtering for, for example, an PrismaClientKnownRequestError.

Environment (please complete the following information):

  • ZenStack version: 2.3.2
  • Prisma version: 5.15.0
  • Database type: Postgresql

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions