Repository navigation
Conversation
When a secondary tag directive is active, parseTag always built a string node from the token after the tag. At EOF that token is nil, so newStringNode panicked. Treat a missing value like parseTagValue does and synthesize an implicit null instead. Fixes goccy#987
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #988 +/- ##
==========================================
+ Coverage 80.65% 80.67% +0.01%
==========================================
Files 22 22
Lines 6845 6851 +6
==========================================
+ Hits 5521 5527 +6
Misses 905 905
Partials 419 419 🚀 New features to boost your workflow:
|
This branch has not been deployed
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.
Summary
When a document declares
%TAG !! …(secondary tag handle),parseTagalways built a string node from the token after the tag. If that value is missing at EOF (for examplea: !!stror- !!str),ctx.currentToken()isnilandnewStringNodepanics with a nil pointer dereference.Without the directive, the same inputs already work:
parseTagValuetreats a nil token as an implicit null. This change mirrors that handling on the secondary-directive path and leaves the non-nil path unchanged.Fixes #987
Test plan
TestIssue987EmptyTaggedValueUnderSecondaryTagDirectivecovering the three inputs from the issue (mapping, sequence, document-level tag).go test -count=1 -run TestIssue987EmptyTaggedValueUnderSecondaryTagDirective .go test -count=1 -timeout 120s .go test -count=1 ./parser/