Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error - Maximum call stack size exceeded #1451

Closed
baenie opened this issue May 14, 2024 · 6 comments · Fixed by #1452
Closed

Error - Maximum call stack size exceeded #1451

baenie opened this issue May 14, 2024 · 6 comments · Fixed by #1452

Comments

@baenie
Copy link
Sponsor

baenie commented May 14, 2024

Description and expected behavior
After trying to upgrade ZenStack to v2, I discovered a bug when trying to call /api/model/membership/findMany (see error message). Every other table was working fine, expect Membership.

After some digging I found out, that it was a field level access policy causing the issue:
@deny("read, update", space.memberships?[auth() == user && !(role in [owner, admin, roleManager])])
After removing the read part, it was working just fine.

This policy was working just fine in v1 of ZenStack, but I tried every v2 release and in every version the error occured.

Error

Error calling enhanced Prisma method `membership.findMany`: Maximum call stack size exceeded
    at RequestHandler.<anonymous> (/<project-path>/node_modules/@zenstackhq/server/api/rpc/index.js:136:57),
    at Generator.next (<anonymous>),
    at fulfilled (/<project-path>/node_modules/@zenstackhq/server/api/rpc/index.js:5:58)

Environment:

  • ZenStack version: 2.0.0 - 2.1.0
  • Prisma version: 5.13.0
  • Database type: Postgresql

Additional context

import "./enum"
import "./user"
import "./space"

model Membership {
  userId            String
  user              User       @relation(fields: [userId], references: [id], onDelete: Cascade)
  spaceId           String
  space             Space      @relation(fields: [spaceId], references: [id], onDelete: Cascade)

  role              MemberRole @deny("update", auth() == user)
  employeeReference String?    @deny("read, update", space.memberships?[auth() == user && !(role in [owner, admin])])

  createdAt         DateTime   @default(now())
  updatedAt         DateTime   @updatedAt

  @@id([userId, spaceId])
}
@iamfj
Copy link
Sponsor

iamfj commented May 14, 2024

@baenie our environment is


Environment:

ZenStack version: 2.1.0
Prisma version: 5.13.0
Database type: Postgresql

@baenie
Copy link
Sponsor Author

baenie commented May 14, 2024

Prisma version: 5.13.0
Database type: Postgresql

But I tested all releases. The bug was introduced in v2.0.0.

@ymc9
Copy link
Member

ymc9 commented May 14, 2024

Thanks for reporting this, guys. I'll try to reproduce and hopefully make a fix soon!

@ymc9
Copy link
Member

ymc9 commented May 15, 2024

Hi @iamfj @baenie , could you try if the new 2.1.1 release fixed the issue?

@baenie
Copy link
Sponsor Author

baenie commented May 15, 2024

Hi @iamfj @baenie , could you try if the new 2.1.1 release fixed the issue?

It seams to work now!
Thank you for your fast response! ❤️

@baenie baenie closed this as completed May 15, 2024
@iamfj
Copy link
Sponsor

iamfj commented May 16, 2024

Thanks! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants