Skip to content

Conversation

@cowtowncoder
Copy link
Member

@cowtowncoder cowtowncoder commented Oct 27, 2025

Summary

Problem:

When using CBOR with string references enabled, deserialization failed if a string value was skipped (e.g., when a property is ignored via @JsonIgnoreProperties). The parser would skip over the string without adding it to the string reference table, causing later string references to fail with "String reference out of range" errors.

Root Cause:

The _skipIncomplete() method in CBORParser was designed to skip over string/bytes content without actually reading it. However, when in a stringref namespace, the parser needs to read and potentially store these values in the reference table for later use.

Solution:

Modified _skipIncomplete() in CBORParser.java (lines 3418-3432) to:

  1. Check if we're in a stringref namespace (!_stringRefs.empty())
  2. If yes, actually read the value using the appropriate finish methods (_finishTextToken() for text, _finishBytes() for bytes)
  3. The finish methods already contain logic to determine if values should be added to the reference table based on shouldReferenceString()
  4. If not in a stringref namespace, use the original skip logic

@cowtowncoder cowtowncoder self-assigned this Oct 27, 2025
@cowtowncoder cowtowncoder added the gen-ai PR created with Generative AI (whole or assisted) (or issue for which gen-ai seems suitable) label Oct 27, 2025
@cowtowncoder cowtowncoder marked this pull request as ready for review October 27, 2025 16:22
@cowtowncoder cowtowncoder merged commit 48149b6 into 2.x Oct 27, 2025
4 checks passed
@cowtowncoder cowtowncoder deleted the claude/2.x/599-fix-string-ref-skipping branch October 27, 2025 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gen-ai PR created with Generative AI (whole or assisted) (or issue for which gen-ai seems suitable)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants