Repository navigation
FIX REST revive of a deleted document skips the changeValidator stored-state check - #484
Merged
pubkey merged 2 commits intoNov 30, 2026
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015P6w6gSU5X3tPquwWNPFbs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015P6w6gSU5X3tPquwWNPFbs
Contributor
✅ Verify Test Reproduction: Tests FAILED without the fix (expected)This confirms the changed tests correctly reproduce the bug that the source changes fix. This workflow runs the changed tests without the source fix to verify they reproduce the bug. Show output |
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.
Bug
The REST
/setand/patchroutes treat a document that is deleted on the server as a new insert, becausecollection.findByIds()does not return deleted documents. They called the endpoint'schangeValidatorwithassumedMasterState: undefinedfor it.The documented readonly-fields validator (
rx-server.md, "Readonly fields") returnstruefor inserts and compares the field withassumedMasterStatefor updates. So a client that is allowed to delete a document could change a readonly field: delete the document with/delete, then revive it with/setand a new value. The replication/pushroute already passes the stored document, deleted or not, asassumedMasterState.Fix
For a revive, the
changeValidatornow gets the stored deleted document (passed throughremoveServerOnlyFields) asassumedMasterState, like the update path and the replication endpoint. Real inserts still getundefined.A validator that blocks inserts with
!change.assumedMasterStatenow treats a revive as a change of the stored document, the same as the replication endpoint does.Test
test/unit/endpoint-rest.test.ts: should run the changeValidator against the stored state when a deleted document is revived. Without the fix, the revive with the changed readonly value is accepted.Full unit suite: 108 passing.
npm run check-typespasses. An independent review confirmed the bug and the fix, including the shape ofassumedMasterState, real inserts, the conflict retry, and the ownership check.This PR touches the same
/setinsert branch as #483 (server-only fields on revive), but a different part of it. Both merge cleanly in either order.Changelog:
orga/changelog/fix-rest-revive-validator.mdGenerated by Claude Code