test(adapters): fix the nesting-depth test under encoding/json v2 - #240
Merged
Conversation
jlexer counts container depth itself because encoding/json v1's Decoder.Token applies no limit of its own. With v2 (GOEXPERIMENT=jsonv2, the default from go1.27) Token enforces the same 10,000-level ceiling first and reports "exceeded max depth", so asserting our own "maximum nesting depth" wording broke. The default-limit subtests now only require that the error wraps ErrStdlib, which is the contract either implementation honours. The wording assertion moves to the WithMaxNestingDepth(5) subtest, where our counter fires long before the stdlib's. defaultMaxNestingDepth documents the interaction: a lower limit rejects earlier than the stdlib, a higher one does not lift the stdlib's ceiling on the decode path. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #240 +/- ##
==========================================
+ Coverage 93.03% 94.46% +1.42%
==========================================
Files 61 61
Lines 3015 3015
==========================================
+ Hits 2805 2848 +43
Misses 166 166
+ Partials 44 1 -43 ☔ View full report in Codecov by Harness. |
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.
jlexer counts container depth itself because encoding/json v1's Decoder.Token applies no limit of its own. With v2 (GOEXPERIMENT=jsonv2, the default from go1.27) Token enforces the same 10,000-level ceiling first and reports "exceeded max depth", so asserting our own "maximum nesting depth" wording broke.
The default-limit subtests now only require that the error wraps ErrStdlib, which is the contract either implementation honours. The wording assertion moves to the WithMaxNestingDepth(5) subtest, where our counter fires long before the stdlib's. defaultMaxNestingDepth documents the interaction: a lower limit rejects earlier than the stdlib, a higher one does not lift the stdlib's ceiling on the decode path.
Change type
Please select: 🆕 New feature or enhancement|🔧 Bug fix'|📃 Documentation update
Short description
Fixes
Full description
Checklist