Skip to content

Conversation

@AaronClaes
Copy link
Contributor

What?

Fix crashing due to unsafe permissions property access in AddNewRelation by safely checking that a collection’s permissions exist before reading its create property.

Why?

Accessing permissions.collections[slug].create throws and breaks the UI when a collection’s permissions entry is missing.
This happens for example when collection‑level access control makes that collection inaccessible.

How?

Change the condition to use optional chaining on the permissions, aligning with usage elsewhere in the codebase:

  • Before: permissions.collections[relatedCollection?.slug].create
  • After: permissions.collections[relatedCollection?.slug]?.create

Copy link
Member

@AlessioGr AlessioGr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@AlessioGr AlessioGr merged commit 127e41a into payloadcms:main Dec 12, 2025
99 checks passed
@github-actions
Copy link
Contributor

🚀 This is included in version v3.68.4

zubricks pushed a commit that referenced this pull request Jan 6, 2026
…14903)

### What?
Fix crashing due to unsafe permissions property access in
`AddNewRelation` by safely checking that a collection’s permissions
exist before reading its `create` property.

### Why?
Accessing `permissions.collections[slug].create` throws and breaks the
UI when a collection’s permissions entry is missing.
This happens for example when collection‑level access control makes that
collection inaccessible.

### How?
Change the condition to use optional chaining on the permissions,
aligning with usage elsewhere in the codebase:
- Before: `permissions.collections[relatedCollection?.slug].create`
- After: `permissions.collections[relatedCollection?.slug]?.create`
teastudiopl pushed a commit to teastudiopl/payload that referenced this pull request Jan 8, 2026
…ayloadcms#14903)

### What?
Fix crashing due to unsafe permissions property access in
`AddNewRelation` by safely checking that a collection’s permissions
exist before reading its `create` property.

### Why?
Accessing `permissions.collections[slug].create` throws and breaks the
UI when a collection’s permissions entry is missing.
This happens for example when collection‑level access control makes that
collection inaccessible.

### How?
Change the condition to use optional chaining on the permissions,
aligning with usage elsewhere in the codebase:
- Before: `permissions.collections[relatedCollection?.slug].create`
- After: `permissions.collections[relatedCollection?.slug]?.create`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants