Repository navigation
fix: findByID returns null for empty ids when disableErrors is true - #18956
Open
Krrishkumar125 wants to merge 1 commit into
Open
Krrishkumar125 wants to merge 1 commit into
Krrishkumar125 wants to merge 1 commit into
Conversation
Author
|
Friendly ping — findByID now returns null for empty/invalid ids when disableErrors is true. Checks are green; happy to revise if you'd rather a different shape. |
This branch has not been deployed
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.
What?
payload.findByID({ id, disableErrors: true })throwsNotFoundagain whenidisnull,undefinedor''. It should returnnull, as it did in 3.90.2 and as the Local API docs describe fordisableErrors.Why?
#18000 (9106bf8) added an explicit
isValidIDguard before the query. That guard throws beforedisableErrorsis checked, so an invalid id became a hard error even with errors disabled. Calls likefindByID({ id: doc.relation, disableErrors: true })with an unset relation now throw (#18935).How?
When the id is invalid and
disableErrorsis set, returnnull; otherwise throwNotFoundas before. Access is still checked first, so an unauthorised caller sees the same result as before.Added
test/collections-rest/findByID-disable-errors.int.spec.ts, which coversnull,undefinedand''with and withoutdisableErrors. Without the fix the threedisableErrorscases fail. Thecollections-rest,versions,access-controlandcollections-graphqlint suites pass locally (SQLite adapter). I put the test in its own file because the existingint.spec.tstrips the pre-commit oxlint hook on some unrelated duplicate test titles.The same guard exists on
3.x; I'm happy to open a backport PR if that's the preferred target for v3 regressions.Fixes #18935