Fix OldSpec byte[] encoding emitting unsupported str8 headers - #2287
Merged
Merged
Conversation
Copilot
AI
changed the title
[WIP] Fix MessagePackWriter.OldSpec ignoring byte[] values for legacy compatibility
Fix OldSpec byte[] encoding emitting unsupported str8 headers
Jul 31, 2026
AArnott
requested changes
Jul 31, 2026
AArnott
left a comment
Collaborator
There was a problem hiding this comment.
@copilot review my feedback.
Contributor
Author
Addressed in 7ec5a75: the OldSpec str16 path now writes a constant |
AArnott
approved these changes
Jul 31, 2026
neuecc
approved these changes
Aug 3, 2026
This was referenced Sep 17, 2026
This was referenced Sep 28, 2026
Open
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.
With
MessagePackWriter.OldSpec = true, writing abyte[]of length 32–255 incorrectly emitted the post-2013str8marker (0xD9), which legacy MessagePack readers cannot decode.Cause
WriteBinHeadercorrectly delegated toWriteStringHeaderin old-spec mode, butWriteStringHeaderalways usedMessagePackPrimitives.TryWriteStringHeader, which selectsstr8for those lengths. Thestringwrite path already avoidedstr8viaWriteString_PostEncoding; header writes did not.Changes
WriteStringHeader: whenOldSpecis set and length is 32–255, emitstr16(0xDA) instead ofstr8Str8as a valid old-spec encodingbyte[]paths at the 31/32/255/256 boundaries and extendOldSpecBinaryFormatterTestwith 32 and 255Example