Skip to content
New issue

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

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

Already on GitHub? # to your account

[Bug] Nested create in update fails policy check from parent field-level update policy on unique field #2007

Open
Gabrola opened this issue Feb 24, 2025 · 0 comments

Comments

@Gabrola
Copy link

Gabrola commented Feb 24, 2025

Description and expected behavior

model Page {
    id String @id @default(cuid())
    title String
    
    images Image[]
    
    @@allow('all', true)
}

model Image {
    id String @id @default(cuid()) @deny('update', true)
    url String
    pageId String?
    page Page? @relation(fields: [pageId], references: [id])
    
    @@allow('all', true)
}
const image = await db.image.create({
    data: {
        url: 'https://example.com/image.png',
    },
});

await db.image.update({
    where: { id: image.id },
    data: {
        page: {
            create: {
                title: 'Page 1',
            },
        },
    },
})
PrismaClientKnownRequestError: denied by policy: Image entities failed 'update' check, entity {"id":"cm7igj9v700004hmokes3ouxz"} failed update policy check for field "id"

This shouldn't error as the id field has not been updated here

Environment:

  • ZenStack version: 2.11.6
@Gabrola Gabrola changed the title [Bug] Nested create fails policy check from parent field-level policy on unique field [Bug] Nested create in update fails policy check from parent field-level update policy on unique field Feb 24, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant