Repository navigation
fix: align TransactionUpdateResult with the native error codes - #131
Merged
SebastianStehle merged 1 commit intoOct 11, 2026
Merged
SebastianStehle merged 1 commit into
SebastianStehle merged 1 commit into
Conversation
The enum was missing the end-of-stream code and shifted every following value by one, so a failed update was reported as the wrong error. For example, an update with an unknown content type (the native UNEXPECTED_VALUE code, 4) was reported as InvalidJson, and an empty or truncated update (end of stream, 3) as UnexpectedValue. Adds EndOfStream, moves the other members to their native values and adds the remaining native codes. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
SebastianStehle
approved these changes
Oct 9, 2026
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.
Summary
Aligns
TransactionUpdateResultwith the error codes returned by the native library, so a failedApplyV1/ApplyV2is reported as the right error.Fixes #130
Problem
Transaction.ApplyV1andApplyV2cast the native error code straight toTransactionUpdateResult. The enum was missing the end-of-stream code, so every value afterIntegerOutOfBoundswas off by one:UnexpectedValueEndOfStreamInvalidJsonUnexpectedValueIntegerOutOfBoundsIntegerOutOfBoundsNative
INVALID_JSON(5) was reported asOther, and nativeOTHER(6) and codes 7 to 9 matched no member at all. The native codes are the same in yrs 0.19.1 (whichmainbuilds against), 0.26 and 0.28.Changes
TransactionUpdateResultnow matches the native codes:OkIoIntegerOutOfBoundsEndOfStreamUnexpectedValueInvalidJsonOtherNotEnoughMemoryTypeMismatchCustomThe doc comment on each member now describes the case that actually produces it.
UnexpectedValuealso notes that it covers content the native library does not know, such as array moves written by yrs 0.26 or older, which yrs 0.27 removed.Tests
New
ApplyErrorTests, which fail onmainand pass with this change:EndOfStreamEndOfStreamIntegerOutOfBoundsUnexpectedValueThe full unit suite passes: 437 passed, 8 skipped, 0 failed. I ran it against a
yrs.dllbuilt from yrs 0.19.1.Notes
UnexpectedValue,InvalidJsonandOtherchange. This only matters to code that persists or compares the raw numbers. Code that only compares againstOk, or against member names, is unaffected except that it now gets the right member. It deserves a line in the release notes.YDotNet.Server/Internal/DocumentContainer.csignores the result ofApplyV1when it loads a stored document, so a document that fails to decode loads as an empty one. Correct codes make that easier to diagnose but do not change it. I left it out to keep this PR to the enum.🤖 Generated with Claude Code