Repository navigation
fix(sdk/go): preserve member path on decode failures - #398
Merged
Merged
Conversation
benbenbang
enabled auto-merge (rebase)
September 30, 2026 15:32
Add memberDecodeError so a member whose raw value the generated decoder cannot unmarshal keeps its full member path when reported. The failure location inside the raw value is preserved and appended to the pointer, while the underlying unmarshal text is dropped so no member value leaks into the surfaced error. A failure already reported by a nested model keeps that model's message, which names the innermost member. The date decode path now uses invalidMemberValueError to report an invalid string value with its member context intact.
…odeError The generated Go models previously returned the bare `err` from `json.Unmarshal` when decoding nullable, empty-or-null, and raw-keyed members, losing the model and wire field context needed to diagnose failures. **Generator changes**: * `gen_go/models.rs` now emits `memberDecodeError(model, wire, raw, err)` in the nullable and empty-or-null codec blocks, threading the model name and wire key into the render helpers. * `render_raw_member` takes the model name and reports raw-keyed member decode failures through `memberDecodeError` for both optional and required members. **Regenerated models**: * All affected `sdk/go/*_models.go` files were regenerated so their member decode paths return `memberDecodeError` with the owning model and wire field instead of a bare error.
Add Go decode-path tests covering nullable members, the empty_or_null and date codecs, and nested-model member locations, asserting that decode errors name the failing member and never leak its raw value. Add a gen_go render test verifying that shadow-decoded members report their failures against the correct member rather than returning the bare unmarshal error. close #387
benbenbang
force-pushed
the
fix/387-go-decode-path
branch
from
September 30, 2026 16:23
769f23c to
6a6bc69
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.
Decode errors from generated Go models previously surfaced the bare error returned by json.Unmarshal, discarding the model and wire field context needed to locate which member failed. This made diagnosing malformed responses difficult and, in some paths, risked leaking raw member values into the surfaced error.
What changed:
Closes #387
close #387