Skip to content

fix(#1365): no non-test code discards a json.Marshal or xml.Marshal error - #1392

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/1365-discarded-marshal
Oct 4, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/1365-discarded-marshal

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

142 sites wrote x, _ := json.Marshal(v) (one xml.Marshal), most of them
feeding state.Put, so a failed encode stored an empty record and answered 200
over state it never recorded. 120 now return the error wrapped with the
plugin and operation. openSearchOK/openSearchStatusOK and EFS's mount-target
counters now return their errors. The health, ready, emails and debug
endpoints answer 500 on a failed encode, and SNS fan-out logs and skips a
subscriber whose payload will not encode.

Ten sites that provably cannot fail are recorded, each with its reason, in
the new scripts/check-discarded-marshal.sh. make discarded-marshal-check fails
on a new discard, keyed by file and enclosing function, and runs in CI. CI now
also runs discarded-unmarshal-check (#1007), which until now ran only through
make.

Fixes #1365

Compatibility

Normal-path responses are byte-identical. Only failure paths that used to be silent change: a failed encode now answers a 500-class error instead of storing an empty record. EFS mount-target create and delete fail if the file system record can't be read or written. A CloudFormation YAML value with non-string keys resolves to its Go rendering instead of "".

…rror

142 sites wrote x, _ := json.Marshal(v) (one xml.Marshal), most of them
feeding state.Put, so a failed encode stored an empty record and answered 200
over state it never recorded. 120 now return the error wrapped with the
plugin and operation. openSearchOK/openSearchStatusOK and EFS's mount-target
counters now return their errors. The health, ready, emails and debug
endpoints answer 500 on a failed encode, and SNS fan-out logs and skips a
subscriber whose payload will not encode.

Ten sites that provably cannot fail are recorded, each with its reason, in
the new scripts/check-discarded-marshal.sh. make discarded-marshal-check fails
on a new discard, keyed by file and enclosing function, and runs in CI. CI now
also runs discarded-unmarshal-check (#1007), which until now ran only through
make.

Fixes #1365
@codecov

codecov Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

@scttfrdmn

Copy link
Copy Markdown
Owner Author

Merging with codecov/patch at 62%, deliberately. The 168 uncovered lines are almost all the new if err != nil { return …, fmt.Errorf("… marshal: %w", err) } branches after a json.Marshal of a fixed-shape value. Those branches exist so the error is never discarded (CLAUDE.md, #1365). They cannot be reached from a test without changing the types being encoded, so a test covering them would exercise nothing real.

The behaviour that is reachable is covered and passes: the four nine-gate checks, go test ./..., lint, and a negative control showing the new discarded-marshal-check fails on a fresh b, _ := json.Marshal(v). Every required check is green; codecov/patch is not a required check.

@scttfrdmn
scttfrdmn merged commit 0da62ff into main Oct 4, 2026
14 of 15 checks passed
@scttfrdmn
scttfrdmn deleted the fix/1365-discarded-marshal branch October 4, 2026 19:53
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.

147 sites discard the error from json.Marshal

1 participant