Skip to content

Conversation

@swittk
Copy link

@swittk swittk commented Oct 7, 2025

Pull Request

Issue

Closes: #9869

Approach

  • Added an opt-in ignoreIncludeErrors boolean 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).
  • When the ignoreIncludeErrors flag is set; Update include hydration 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.
    • Edited the database controller to bypass the 101 error for nested FETCH/GET operations only when the option is enabled, while preserving all ACL/CLP enforcement.
  • Added REST tests that cover both unreadable pointers and partially missing arrays to prove the relaxed behaviour.

Tasks

  • Add tests
  • Add changes to documentation (guides, repository pages, code comments)

Summary by CodeRabbit

  • New Features

    • Added an optional ignoreIncludeErrors flag for GET/FIND requests to preserve unreadable or unresolved included pointers (including inside arrays) and return 200 instead of failing.
  • Behavior

    • Default behavior unchanged: without the flag, requests may return 404/OBJECT_NOT_FOUND when includes can’t be hydrated.
  • Tests

    • Added tests covering unreadable/unresolved include pointers and array scenarios with and without the flag.

@parse-github-assistant
Copy link

parse-github-assistant bot commented Oct 7, 2025

🚀 Thanks for opening this pull request!

@coderabbitai
Copy link

coderabbitai bot commented Oct 7, 2025

📝 Walkthrough

Walkthrough

Adds 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

Cohort / File(s) Summary of Changes
Tests: include error tolerance
spec/rest.spec.js
Adds tests for ignoreIncludeErrors: unreadable pointers preserved as Pointer objects when flag is true; arrays preserve unresolved pointers; 404 returned when include hydration fails without the flag.
Routing / request parsing
src/Routers/ClassesRouter.js
Accepts ignoreIncludeErrors in GET query params and FIND bodies, coerces/validates to boolean, and includes it in the options passed to REST handling; updates allowed GET query keys.
Query options surface
src/Adapters/Storage/StorageAdapter.js
Adds ignoreIncludeErrors?: boolean to the QueryOptions type.
Database get/find behavior
src/Controllers/DatabaseController.js
Adds ignoreIncludeErrors to find options; when op is 'get' and permission/include filtering yields no query, returns [] instead of throwing OBJECT_NOT_FOUND if the flag is true.
Include resolution and pointer replacement
src/RestQuery.js
Propagates ignoreIncludeErrors via preserveMissing; replacePointers now accepts an options param and preserves unresolved/unreadable pointers (including array elements) when requested; threads options through recursive calls.

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
Loading
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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Pay attention to:
    • Correct propagation of ignoreIncludeErrors through REST/Router -> RestQuery -> DatabaseController -> StorageAdapter.
    • Behavior changes in DatabaseController.find when returning [] vs throwing OBJECT_NOT_FOUND for op='get'.
    • replacePointers recursion and array handling when preserveMissing is enabled.
    • Type change in QueryOptions and any TypeScript/flow impacts.

Suggested reviewers

  • Moumouls

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Title Check ✅ Passed The PR title "feat: Ignore missing include targets (on fetch & query) with optional ignoreIncludeErrors flag" clearly and concisely summarizes the primary change: introducing an optional flag to gracefully handle missing include targets. The title is specific enough to convey the feature's purpose and directly reflects the main objective of the changeset across all modified files (StorageAdapter, DatabaseController, RestQuery, ClassesRouter, and tests).
Linked Issues Check ✅ Passed The PR addresses the core requirements from issue #9869. The linked issue requests a backwards-compatible option to prevent include queries from failing when included pointers are deleted or unreadable, with the proposal suggesting modes including 'pointer' (return as raw pointer JSON). The implementation provides an opt-in ignoreIncludeErrors boolean flag that, when enabled, implements the 'pointer' mode by preserving unresolved pointers as raw pointer JSON instead of throwing errors, preserves array ordering with missing entries as pointers, maintains ACL/CLP enforcement, and defaults to the strict behavior (throwing errors), satisfying the primary objective of solving the root query failure problem while surfacing missing includes in a tolerant way.
Out of Scope Changes Check ✅ Passed All code changes are directly related to implementing the ignoreIncludeErrors feature as described in issue #9869 and the PR objectives. The modifications span from storage adapters (QueryOptions type), database controller (error handling logic), REST query handling (preserveMissing pointer replacement), routing layer (parameter propagation), and corresponding test coverage. No extraneous changes such as refactoring, unrelated bug fixes, or feature modifications outside the scope of this feature are present in the changeset.
Description Check ✅ Passed The PR description follows the repository template structure and includes all required sections: Issue (linked to #9869), Approach (explaining the feature implementation including the preserveMissing behavior and ACL/CLP enforcement), and Tasks (marking tests and documentation as completed). The description provides sufficient context about the implementation, including how unresolved pointers are preserved as raw pointer JSON and how arrays maintain their ordering. While some template sections like security checks are not explicitly addressed, the core required information is present and complete.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@parseplatformorg
Copy link
Contributor

parseplatformorg commented Oct 7, 2025

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@swittk swittk changed the title Feature: Ignore missing include targets (on fetch & query) with optional ignoreIncludeErrors flag. feature: Ignore missing include targets (on fetch & query) with optional ignoreIncludeErrors flag. Oct 7, 2025
Copy link

@coderabbitai coderabbitai bot left a 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

We’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

📥 Commits

Reviewing files that changed from the base of the PR and between be362fe and 7e4e987.

📒 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)

@swittk swittk changed the title feature: Ignore missing include targets (on fetch & query) with optional ignoreIncludeErrors flag. feat: Ignore missing include targets (on fetch & query) with optional ignoreIncludeErrors flag. Oct 7, 2025
Copy link

@coderabbitai coderabbitai bot left a 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 preserveMissing we keep the original pointer object, so arrays shouldn’t accrue undefined entries. 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

📥 Commits

Reviewing files that changed from the base of the PR and between 7e4e987 and 1c2b0e2.

📒 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

Copy link

@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between e287f10 and ccc9cad.

📒 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 ignoreIncludeErrors option is correctly added to the list of options propagated from restOptions to findOptions, following the established pattern for other query options.


1023-1029: LGTM! Correct flag derivation and propagation.

The preserveMissing flag is properly derived from restOptions.ignoreIncludeErrors with appropriate defaults, and the option is correctly propagated to includeRestOptions for nested include operations.


1071-1073: LGTM! Options correctly passed to replacePointers.

The preserveMissing flag is properly passed through to replacePointers via the options object.


1118-1154: LGTM! Solid implementation of preserveMissing logic.

The implementation correctly handles the preserveMissing option:

  • Defaults safely with options = {} and !!options.preserveMissing
  • Arrays preserve unresolved pointers when preserveMissing is true, or filter them when false
  • Leaf pointer replacement returns the original pointer object when replacement is missing and preserveMissing is true
  • Options are properly threaded through recursive calls

This maintains backward compatibility (default strict behavior) while enabling the new tolerant include resolution mode.

Comment on lines +1114 to 1116
// `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
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

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.

Suggested change
// `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
Copy link

codecov bot commented Oct 25, 2025

Codecov Report

❌ Patch coverage is 94.44444% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 93.01%. Comparing base (b298ccc) to head (ccc9cad).
⚠️ Report is 1 commits behind head on alpha.

Files with missing lines Patch % Lines
src/Routers/ClassesRouter.js 75.00% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

include on Queries can cause root query to fail with 101 when an included pointer is deleted / unreadable, without indicating which parent field failed.

3 participants