Skip to content

compatible_shim: clear all unused fields on UnmarshalJSON() - #91

Merged
kennytm merged 1 commit into
masterfrom
kennytm/initialize-all-fields-in-json-unmarshal
Nov 12, 2026
Merged

kennytm merged 1 commit into
masterfrom
kennytm/initialize-all-fields-in-json-unmarshal

Conversation

@kennytm

@kennytm kennytm commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the change to clear stale state after successful JSON unmarshalling.

No open issues 🎉

What changed in this PR

Updates Error.UnmarshalJSON() to clear stale local state when decoding successfully into an existing error.

Changes:

  • Clears arguments, cause, redaction positions, and source location after successful decoding.
  • Adds regression tests for state clearing, literal message preservation through JSON round-trips, and unchanged receiver state on invalid input.
File Description
compatible_shim.go Resets fields not populated by JSON after successful unmarshalling.
compatible_shim_test.go Tests successful state clearing, message preservation, and invalid-input handling.

Review effort: Balanced

@kennytm
kennytm merged commit e508e77 into master Nov 12, 2026
2 checks passed
@kennytm
kennytm deleted the kennytm/initialize-all-fields-in-json-unmarshal branch November 12, 2026 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants