Repository navigation
Fix Encoder panic for unsupported pointer fields - #259
Open
skyon0522-ai wants to merge 1 commit into
Open
skyon0522-ai wants to merge 1 commit into
skyon0522-ai wants to merge 1 commit into
Conversation
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.
What type of PR is this? (check all applicable)
Description
Encoder.Encodecan panic when a non-nil pointer to an unsupported type reaches a pointer encoder with no underlying callback. Dereference non-nil, unregistered pointers before selecting an encoder so these values take the existingMultiErrorpath. For slices, collect values before replacing the destination entry, preserving it if a later element is unsupported.This keeps registered pointer encoders, existing
"null"output for nil pointers,omitempty, and struct-pointer recursion. It does not introduce an encoding format for unsupported types. Prepared with Codex assistance.Related Tickets & Documents
Added/updated tests?
Run verifications and test
make verifyis passing. It failed locally at lint: 14 findings (5govet, 9staticcheck) exactly match the untouched pinned upstream baseline under golangci-lint 2.15.0 and Go 1.27.2. The separately runmake gosecfailed with six G115 findings, all matching the upstream baseline in unchangedconverter.go.make govulncheckexited successfully: no affected code vulnerabilities; one required-module vulnerability was reported as not called. These comparisons found no new findings, but do not makemake verifypass.make testis passing. On Ubuntu 24.04 with Go 1.27.2, the race-enabled suite passed with 92.7% statement coverage;go vet ./...andgofmtpassed. An unchanged 15-case pointer matrix also passed, including three nil-output observations matching the pinned baseline.The repository's Go 1.20/1.21 CI and golangci-lint 1.53 were not run here; nor were Windows or macOS checks.