Skip to content

feat: add disableErrors to global find#6357

Closed
denolfe wants to merge 1 commit into
2.xfrom
feat/globals-disable-errors
Closed

feat: add disableErrors to global find#6357
denolfe wants to merge 1 commit into
2.xfrom
feat/globals-disable-errors

Conversation

@denolfe

@denolfe denolfe commented May 14, 2024

Copy link
Copy Markdown
Member

Add disableErrors to global find.

@denolfe denolfe added the v2 label Dec 3, 2024
@denolfe denolfe closed this Dec 20, 2024
@denolfe denolfe deleted the feat/globals-disable-errors branch December 20, 2024 20:30
paulpopus pushed a commit that referenced this pull request Apr 2, 2026
### What?

This PR introduces the `disableErrors` option into the global `findOne`
operation.

### Why?

`disableErrors` is handy for certain flows where a user may be
unauthorised but you don't need an error to be thrown, instead you would
prefer an empty result.

Without this, the developer needs to catch the error themselves, leading
to inconsistencies as some operations have `disableErrors` and others do
not.

### How?

Introduced the `disableErrors` option to the global `findOne` operation.

### Additional information

- Initial [discord
discussion](https://discord.com/channels/967097582721572934/1102950643259424828/1438504179961430059).
- A [PR](#6357) was created to
address this in mid 2024 but was later closed.
- There is opportunity here to include `disableErrors` in a number of
operations that seem to be lacking it, especially in the `sdk` package.
Originally I included these changes in this PR but have since removed to
instead allow for some discussion before we consider introducing them in
a separate PR.
- There is opportunity to introduce better test coverage in a separate
PR for `disableErrors` across existing operations that use it.
- In `packages/payload/src/collections/operations/restoreVersion.ts`,
`disableErrors` exists in the types but is not actually implemented. I
have left this as is for now but wanted to flag it.
milamer pushed a commit to milamer/payload that referenced this pull request Apr 20, 2026
…cms#14913)

### What?

This PR introduces the `disableErrors` option into the global `findOne`
operation.

### Why?

`disableErrors` is handy for certain flows where a user may be
unauthorised but you don't need an error to be thrown, instead you would
prefer an empty result.

Without this, the developer needs to catch the error themselves, leading
to inconsistencies as some operations have `disableErrors` and others do
not.

### How?

Introduced the `disableErrors` option to the global `findOne` operation.

### Additional information

- Initial [discord
discussion](https://discord.com/channels/967097582721572934/1102950643259424828/1438504179961430059).
- A [PR](payloadcms#6357) was created to
address this in mid 2024 but was later closed.
- There is opportunity here to include `disableErrors` in a number of
operations that seem to be lacking it, especially in the `sdk` package.
Originally I included these changes in this PR but have since removed to
instead allow for some discussion before we consider introducing them in
a separate PR.
- There is opportunity to introduce better test coverage in a separate
PR for `disableErrors` across existing operations that use it.
- In `packages/payload/src/collections/operations/restoreVersion.ts`,
`disableErrors` exists in the types but is not actually implemented. I
have left this as is for now but wanted to flag it.
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.

1 participant