Repository navigation
Raise ConstructorError for values that do not fit their explicit tag - #282
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #282 +/- ##
==========================================
+ Coverage 92.17% 92.21% +0.03%
==========================================
Files 15 15
Lines 1751 1759 +8
==========================================
+ Hits 1614 1622 +8
Misses 137 137 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…rError Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A scalar with an explicit tag its text cannot satisfy threw a Base error: KeyError for '!!bool y', ArgumentError for '!!int abc', '!!float abc', and '!!binary 0', and InvalidCharError for invalid UTF-8 text. A collection or scalar tagged '!!map' threw MethodError. The bool, int, float, and binary constructors now convert their text through one helper that turns a rejected conversion into a ConstructorError at the node, and construct_mapping checks the node kind, as construct_sequence and construct_scalar already do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
quinnj-bot
Bot
force-pushed
the
claude/wrong-tag-errors
branch
from
November 18, 2026 14:03
487044f to
ad37c11
Compare
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.
Why
A value whose explicit tag doesn't fit its text throws a Base error with no position:
!!bool ythrowsKeyError.!!int abc,!!float abc, and!!binary 0throwArgumentError.!!map xand!!map [1]throwMethodError.!!floattext with invalid UTF-8 throwsInvalidCharError.Callers that catch YAML.jl's errors to report bad input miss all of these.
What changed
construct_parsed_scalar. When the conversion throws, the helper raisesConstructorError("could not convert \"abc\" to tag:yaml.org,2002:int")at the node.construct_mappingnow checks that the node is a mapping and raisesConstructorErrorotherwise, asconstruct_sequenceandconstruct_scalaralready do. Every mapping path goes through it: the defaultDict, a customdicttype, and!!map.ArgumentErrorfor!!int 0b102,!!int 0b,!!int 1 2, and the!!floatforms rejected by Read only decimal text through the BigFloat fallback for floats #277 now expectConstructorError.No issue was filed. Round 4's fuzz found this.
!!timestampis handled separately in the impossible-dates PR.Verification
ArgumentError.Pkg.test()passes on Julia 1.12.6 and on Julia 1.0.5 in Docker.ArgumentErrors from binary, 173MethodErrors fromconstruct_mapping, 120KeyErrors from bool, 104ArgumentErrors fromparse_int, 97ArgumentErrors from float, and 1InvalidCharError. With this fix, there are 0.tryper scalar costs nothing measurable.🤖 Generated with Claude Code