Repository navigation
Return an error instead of panicking when Set targets a pointer to a nil map - #164
Merged
Merged
Conversation
when passed a pointer to a nil map. * fixes #163 Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Signed-off-by: Frédéric BIDON <fredbi@yahoo.com>
fredbi
force-pushed
the
copilot/fix-nil-map-pointer-panics
branch
from
November 17, 2026 19:43
4bd5952 to
1da7acf
Compare
fredbi
marked this pull request as ready for review
November 17, 2026 19:45
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #164 +/- ##
==========================================
+ Coverage 93.72% 93.74% +0.01%
==========================================
Files 5 5
Lines 669 671 +2
==========================================
+ Hits 627 629 +2
Misses 42 42 ☔ 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.
Pointer.SetandSetForTokenreturned an error for a nil map passed by value, but panicked withassignment to entry in nil mapwhen given a pointer to a nil map. This happens with a zero-value map or one decoded from JSONnull.pointer.gosetSingleImplnow checks whether the map is nil in itsreflect.Mapbranch, before callingSetMapIndex.isNil(node)check only sees the non-nil pointer, so it didn't catch this case.cannot set field %q on nil value, wrappingErrPointer.pointer_test.goTestSetPointerToNilMap. It coversPointer.SetandSetForTokenand asserts that neither panics and that the error wrapsErrPointer.Nil maps are rejected rather than allocated, which matches the existing by-value behavior and the package's rule of not creating intermediate values.