-
-
Couldn't load subscription status.
- Fork 4.8k
feat: Ignore missing include targets (on fetch & query) with optional ignoreIncludeErrors flag.
#9872
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: alpha
Are you sure you want to change the base?
Conversation
|
🚀 Thanks for opening this pull request! |
📝 WalkthroughWalkthroughAdds a per-request ignoreIncludeErrors flag propagated from routers into RestQuery and DatabaseController.find; threads a preserveMissing option through pointer replacement to preserve unresolved/unreadable pointers during include resolution; tests added to validate behavior. No public API removals. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant C as Client
participant R as ClassesRouter
participant Q as RestQuery
participant D as DatabaseController
participant S as StorageAdapter
Note over C,R: GET /classes/:Class/:id?include=...&ignoreIncludeErrors=true
C->>R: HTTP GET (include + ignoreIncludeErrors=true)
R->>Q: build RestQuery (ignoreIncludeErrors=true)
Q->>D: find(op='get', options.ignoreIncludeErrors=true)
D->>S: query for include targets
alt include targets unreadable/missing
S-->>D: no readable matches
D-->>Q: return [] (instead of OBJECT_NOT_FOUND due to flag)
else include targets found
S-->>D: matched records
D-->>Q: include records
end
Q->>Q: replacePointers(preserveMissing=true)
Note over Q: unresolved/unreadable pointers preserved as Pointer objects
Q-->>R: result with preserved pointers
R-->>C: 200 OK
sequenceDiagram
autonumber
participant C as Client
participant R as ClassesRouter
participant Q as RestQuery
participant D as DatabaseController
Note over C,R: GET with include, ignoreIncludeErrors not set
C->>R: HTTP GET (include)
R->>Q: build RestQuery (no ignoreIncludeErrors)
Q->>D: find(op='get', options.ignoreIncludeErrors=false)
alt include permission/filtering removes target
D-->>Q: throws OBJECT_NOT_FOUND
Q-->>R: propagate error
R-->>C: 404 OBJECT_NOT_FOUND
else include targets resolved
D-->>Q: include records
Q-->>R: hydrated object
R-->>C: 200 OK
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
include targets (on fetch & query) with optional ignoreIncludeErrors flag.include targets (on fetch & query) with optional ignoreIncludeErrors flag.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/RestQuery.js (1)
1116-1119: Clean up the lingering TODOWe’re shipping with a TODO that questions whether the new behavior is correct; please replace it with a concrete explanation (or remove it) so the intent is clear to future readers.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
spec/rest.spec.js(1 hunks)src/Adapters/Storage/StorageAdapter.js(1 hunks)src/Controllers/DatabaseController.js(2 hunks)src/RestQuery.js(7 hunks)src/Routers/ClassesRouter.js(4 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
src/Routers/ClassesRouter.js (2)
src/PromiseRouter.js (1)
body(141-141)src/Controllers/DatabaseController.js (1)
options(1790-1790)
spec/rest.spec.js (2)
src/RestQuery.js (1)
schemaController(789-789)src/rest.js (1)
schemaController(71-71)
include targets (on fetch & query) with optional ignoreIncludeErrors flag.include targets (on fetch & query) with optional ignoreIncludeErrors flag.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/RestQuery.js (1)
1116-1119: Clean up the lingering TODO.This TODO leaves an unresolved question in production code. With
preserveMissingwe keep the original pointer object, so arrays shouldn’t accrueundefinedentries. Please drop the TODO (or replace it with a concrete assertion/test) before merging.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
spec/rest.spec.js(1 hunks)src/RestQuery.js(7 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- spec/rest.spec.js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
spec/rest.spec.js(1 hunks)src/Controllers/DatabaseController.js(2 hunks)src/RestQuery.js(7 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- spec/rest.spec.js
- src/Controllers/DatabaseController.js
🔇 Additional comments (4)
src/RestQuery.js (4)
212-222: LGTM! Clean option propagation.The
ignoreIncludeErrorsoption is correctly added to the list of options propagated fromrestOptionstofindOptions, following the established pattern for other query options.
1023-1029: LGTM! Correct flag derivation and propagation.The
preserveMissingflag is properly derived fromrestOptions.ignoreIncludeErrorswith appropriate defaults, and the option is correctly propagated toincludeRestOptionsfor nested include operations.
1071-1073: LGTM! Options correctly passed to replacePointers.The
preserveMissingflag is properly passed through toreplacePointersvia the options object.
1118-1154: LGTM! Solid implementation of preserveMissing logic.The implementation correctly handles the
preserveMissingoption:
- Defaults safely with
options = {}and!!options.preserveMissing- Arrays preserve unresolved pointers when
preserveMissingis true, or filter them when false- Leaf pointer replacement returns the original pointer object when replacement is missing and
preserveMissingis true- Options are properly threaded through recursive calls
This maintains backward compatibility (default strict behavior) while enabling the new tolerant include resolution mode.
| // `options` is an optional options object; options currently include | ||
| // `preserveMissing?: boolean` where if it is true | ||
| // Returns something analogous to object, but with the appropriate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: Incomplete comment.
The comment has an incomplete sentence: "where if it is true" ends abruptly.
Consider completing the sentence:
-// `options` is an optional options object; options currently include
-// `preserveMissing?: boolean` where if it is true
+// `options` is an optional options object; options currently include:
+// `preserveMissing?: boolean` - if true, missing pointer replacements are kept as-is📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| // `options` is an optional options object; options currently include | |
| // `preserveMissing?: boolean` where if it is true | |
| // Returns something analogous to object, but with the appropriate | |
| // `options` is an optional options object; options currently include: | |
| // `preserveMissing?: boolean` - if true, missing pointer replacements are kept as-is | |
| // Returns something analogous to object, but with the appropriate |
🤖 Prompt for AI Agents
In src/RestQuery.js around lines 1114 to 1116, the comment block ends with an
incomplete sentence ("where if it is true"). Update the comment to complete that
sentence and make the behavior clear (for example: explain what preserveMissing
true does — e.g., "where if it is true, missing properties on the source object
should be preserved in the result instead of being omitted"), and ensure the
full comment reads as a complete description of the options and the returned
value.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## alpha #9872 +/- ##
==========================================
- Coverage 93.01% 93.01% -0.01%
==========================================
Files 187 187
Lines 15163 15176 +13
Branches 177 177
==========================================
+ Hits 14104 14116 +12
- Misses 1047 1048 +1
Partials 12 12 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Pull Request
Issue
Closes: #9869
Approach
ignoreIncludeErrorsboolean query option that flows from the routers through RestQuery, defaulting to the existing strict behaviour (throws Parse.Error.OBJECT_OBJECT_NOT_FOUND when included fields on Query/FetchWithInclude are no longer accessible).ignoreIncludeErrorsflag is set; Updateincludehydration with so unresolved pointers are left in place instead of throwing (current behavior) when the flag is set; arrays keep their original ordering and any missing entries stay as raw pointer JSON.Tasks
Summary by CodeRabbit
New Features
Behavior
Tests