feat: add disableErrors to global find#6357
Closed
denolfe wants to merge 1 commit into
Closed
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add
disableErrorsto global find.