Repository navigation
Skip CBOR data item when destination struct has incorrect tags - #821
Merged
fxamacker merged 1 commit intoSep 17, 2026
Merged
Conversation
This commit skips the CBOR data item in parseArrayToStruct() and parseMapToStruct() if the destination struct has incorrect tags (e.g. struct tag specifies "keyasint" but struct field name cannot be parsed as an integer). Skipping the CBOR data item advances the data offset to the next CBOR data item so that the next CBOR data item can be parsed if needed. The commit also includes the following changes in test code: - add test helper functions to check that Unmarshal() advances the data offset to the next CBOR data item on success and on error for well-formed CBOR data - update all relevant call sites in 6 test files to use the helper functions
x448
approved these changes
Sep 17, 2026
fxamacker
added a commit
that referenced
this pull request
Sep 18, 2026
…tag-error Port #821 from release-2.9 to master
fxamacker
deleted the
fxamacker/release-2.9-skip-data-on-struct-tag-error
branch
October 1, 2026 23:32
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.
This issue is unlikely to be encountered in practice, because it requires user apps to use incorrect struct tags, which is detected on the first attempt to decode anything into the struct (i.e., during testing).
This PR skips the CBOR data item in
parseArrayToStruct()andparseMapToStruct()if the destination struct has incorrect tags (e.g. struct tag specifies "keyasint" but struct field name cannot be parsed as an integer). Skipping the CBOR data item advances the data offset to the next CBOR data item so that the next CBOR data item can be parsed if needed.The PR also includes the following changes in test code:
Unmarshal()advances the data offset to the next CBOR data item on success and on error for well-formed CBOR data