Skip to content

Fail loading when stored document data cannot be applied - #138

Open
jcannon98188 wants to merge 2 commits into
y-crdt:mainfrom
jcannon98188:fix/surface-apply-errors
Open

jcannon98188 wants to merge 2 commits into
y-crdt:mainfrom
jcannon98188:fix/surface-apply-errors

Conversation

@jcannon98188

Copy link
Copy Markdown
Contributor

Summary

Fixes #135

DocumentContainer ignored the result of ApplyV1 when loading a stored document. Undecodable data produced an empty document, and the next write replaced the stored record with it.

Changes

  • LoadCoreAsync checks the TransactionUpdateResult and throws a YDotNetException naming the document and the result code.
  • The loading task faults, so callers see the error and the writer never runs.

Tests

Added to DocumentContainerTests:

  • FailsWhenStoredDocumentCannotBeApplied: 12 × 0xFF as stored data. It expects a YDotNetException, and that StoreDocAsync is never called. Fails without the fix (Expected: <YDotNet.YDotNetException>) and passes with it.
  • LoadsStoredDocument: a valid stored update still loads its content.

DocumentContainerTests: 3 passed. I did not run the rest of the server test project, because the storage fixtures need databases.

Notes

🤖 Generated with Claude Code

DocumentContainer ignored the result of ApplyV1, so undecodable stored data
produced an empty document that the next write persisted over the original.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…d data

The fixture shared its fakes across tests, so StoreImmediately depended on test order. Its
unconfigured storage fake also returned an empty array, which only loaded because the apply
result used to be ignored. Recreate the fakes per test and return no stored document.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@jcannon98188

Copy link
Copy Markdown
Contributor Author

Updated tests so they align with implementations behavior

@SebastianStehle

Copy link
Copy Markdown
Collaborator

There are conflicts now

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.

DocumentContainer loads an empty document when stored data fails to apply, and the next write overwrites it

2 participants