Skip to content

fix: Preserve sibling fields in afterSave and LiveQuery snapshots - #10910

Open
charan-rathore wants to merge 1 commit into
parse-community:alphafrom
charan-rathore:fix/10908-nested-save-event-snapshot
Open

charan-rathore wants to merge 1 commit into
parse-community:alphafrom
charan-rathore:fix/10908-nested-save-event-snapshot

Conversation

@charan-rathore

@charan-rathore charan-rathore commented Nov 29, 2026 •

Copy link
Copy Markdown

Issue

Fixes #10908.

Approach

The SDK pops the pending operations before merging the fields returned by the database. Parse Server now captures the attribute estimate before calling the SDK so the merge retains sibling writes alongside the authoritative atomic-operation result.

Tasks

  • Add regression tests for afterSave, the save response, and LiveQuery without an afterSave trigger.
  • Explain the ordering dependency in a code comment.

Verification

On Maritime with MongoDB 8.0.4, the three targeted regression cases failed on the upstream base and passed with the patch. The complete spec/CloudCode.spec.js and spec/ParseLiveQuery.spec.js run reported 367 specs, zero failures, and one pending spec.

@parse-github-assistant

Copy link
Copy Markdown

🚀 Thanks for opening this pull request! We appreciate your effort in improving the project. Please let us know once your pull request is ready for review.

Tip

  • Keep pull requests small. Large PRs will be rejected. Break complex features into smaller, incremental PRs.
  • Use Test Driven Development. Write failing tests before implementing functionality. Ensure tests pass.
  • Group code into logical blocks. Add a short comment before each block to explain its purpose.
  • We offer conceptual guidance. Coding is up to you. PRs must be merge-ready for human review.
  • Our review focuses on concept, not quality. PRs with code issues will be rejected. Use an AI agent.
  • Human review time is precious. Avoid review ping-pong. Inspect and test your AI-generated code.

Note

Please respond to review comments from AI agents just like you would to comments from a human reviewer. Let the reviewer resolve their own comments, unless they have reviewed and accepted your commit, or agreed with your explanation for why the feedback was incorrect.

Caution

Pull requests must be written using an AI agent with human supervision. Pull requests written entirely by a human will likely be rejected, because of lower code quality, higher review effort and the higher risk of introducing bugs. Please note that AI review comments on this pull request alone do not satisfy this requirement. Our CI and AI review are safeguards, not development tools. If many issues are flagged, rethink your development approach. Invest more effort in planning and design rather than using review cycles to fix low-quality code.

@coderabbitai

coderabbitai Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

handleSaveResponse now captures the attribute estimate before defining its temporary getter. REST regression tests check nested increment updates in save responses, afterSave triggers, and LiveQuery events.

Changes: Nested Increment Updates

Layer / File(s) Summary
Capture the attribute estimate
src/RestWrite.js
handleSaveResponse computes the attribute estimate before defining the temporary attributes getter.
Verify nested update snapshots
spec/CloudCode.spec.js, spec/ParseLiveQuery.spec.js
Tests check that nested sibling values are preserved and that the stored value matches the save response, afterSave object, and LiveQuery update object.

Estimated code review effort: 2 (Simple) | ~10 minutes

Severity of issue fixed: Medium

Suggested reviewers: mtrezza

Merge Risk: Minimal · up to 8ecce

This change keeps sibling nested fields in afterSave objects, save responses and LiveQuery updates when a dotted Increment is combined with other writes to the same field. It is a small, easily reverted ordering fix with targeted regression tests. No merge-blocking risk was found. Nesting two or more levels deep behaves as before and could be handled in a separate follow-up.

Pre-merge checks: Passed 6

Check name Status Explanation
Title check Passed The title begins with the required prefix "fix:" and the first letter after the prefix is capitalized ("Preserve"). It clearly summarizes the main change: preserving sibling fields in afterSave and Li…
Linked Issues check Passed Issue #10908 asks that afterSave objects, the save response, and LiveQuery update events keep sibling values written after a dot-notation Increment on the same field. The diff in src/RestWrite.js move…
Out of Scope Changes check Passed All changes map to issue #10908. The src/RestWrite.js change is limited to handleSaveResponse, with a comment that explains the ordering dependency. The spec changes add regression tests for the repor…
Description check Passed The description follows the repository template in structure. It has the Issue section linking #10908, an Approach section that explains the ordering change, and checked Tasks for regression tests and…
Security Check Passed The Security check passes. I reviewed the full source diff for PR #10910 (refs/coderabbit/pre-merge-check/base..head). The changed files are spec/CloudCode.spec.js, spec/ParseLiveQuery.spec.js, …
Engage In Review Feedback Passed The check applies to review feedback comments. The supplied review context states that no CodeRabbit review threads were returned for this pull request. No review feedback exists, so none was ignored …
Full details: Title check

Explanation

The title begins with the required prefix "fix:" and the first letter after the prefix is capitalized ("Preserve"). It clearly summarizes the main change: preserving sibling fields in afterSave and LiveQuery snapshots, which matches the linked issue and the RestWrite.js ordering fix with its regression tests.

Full details: Linked Issues check

Explanation

Issue #10908 asks that afterSave objects, the save response, and LiveQuery update events keep sibling values written after a dot-notation Increment on the same field. The diff in src/RestWrite.js moves the attribute estimate in handleSaveResponse to run before the SDK's _handleSaveResponse merge. The getter now returns that fixed snapshot instead of computing the estimate lazily after pending operations are popped. The issue notes that null or Delete before the value does not trigger the bug, which matches this ordering cause. The PR adds regression tests in spec/CloudCode.spec.js (afterSave and save response, with and without a preceding stats.title update) and spec/ParseLiveQuery.spec.js (update event object, with no afterSave trigger). These tests cover the three affected paths named in the issue. I did not execute the tests. The PASS relies on the code diff, the test summaries, and the author's report that the targeted tests failed on base and passed with the patch.

Full details: Out of Scope Changes check

Explanation

All changes map to issue #10908. The src/RestWrite.js change is limited to handleSaveResponse, with a comment that explains the ordering dependency. The spec changes add regression tests for the reported afterSave, save response, and LiveQuery behavior. No unrelated files or behavior changes appear in the summary. The change to the attributes getter (fixed value instead of lazy computation) is the direct mechanism for the fix and does not change other behavior described in the summary. The related issues #10906 and #10907 are mentioned in the issue notes only and are not claimed by this PR.

Full details: Description check

Explanation

The description follows the repository template in structure. It has the Issue section linking #10908, an Approach section that explains the ordering change, and checked Tasks for regression tests and a code comment. It includes a Verification section with test results. It does not include the template's license and security policy lines, and it does not address the documentation, security check, or Parse JS SDK error code tasks. These are non-critical for this change, so the description is mostly complete.

Full details: Security Check

Explanation

The Security check passes. I reviewed the full source diff for PR #10910 (refs/coderabbit/pre-merge-check/base..head). The changed files are spec/CloudCode.spec.js, spec/ParseLiveQuery.spec.js, and src/RestWrite.js. The only production change is in handleSaveResponse in src/RestWrite.js. The lazy attributes ??= estimateAttributes.call(this) getter is replaced by an eager const attributes = estimateAttributes.call(this). The getter then returns that fixed value. The change only moves when the same estimate is computed. It does not change what data is computed, who can read it, or what is returned to clients. I checked the change against the common advisory categories: - No authentication, authorization, or ACL check is removed or weakened. - No new input is parsed or trusted. No injection surface (query, command, or regex) is added. - No secret, key, or credential handling is changed. - No new field is exposed. The tests add coverage for sibling fields in afterSave, the save response, and LiveQuery. Those fields come from the caller's own write. - No new dependency or unsafe deserialization is introduced. The remaining risk is a possible performance change, because the estimate now runs even if the SDK never reads the attributes. That is not a security issue under this check's criteria.

Full details: Engage In Review Feedback

Explanation

The check applies to review feedback comments. The supplied review context states that no CodeRabbit review threads were returned for this pull request. No review feedback exists, so none was ignored or resolved without discussion. The check therefore has no failing condition to meet. Discussion and resolution states are unavailable for this PR, but they do not matter here because no threads exist. I did not inspect the code for this check because the criterion concerns only feedback engagement.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 20904be5-6e06-4851-b79a-81a807543955
Commits

Reviewing files that changed from the base of the PR and between 384b473 and 8ecce49.

Files selected for processing: 3

  • spec/CloudCode.spec.js
  • spec/ParseLiveQuery.spec.js
  • src/RestWrite.js

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

This branch has not been deployed

No deployments
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.

Object in afterSave and LiveQuery events leaves out a dot notation value that follows a dot notation Increment of the same field

1 participant