{"record":{"id":"1c63664a4ac24a64","repo":"moonD4rk/HackBrowserData","slug":"decode-dump-w","errorCode":null,"errorMessage":"decode dump: %w","messagePattern":"decode dump: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"masterkey/dump.go","lineNumber":78,"sourceCode":"\treturn h\n}\n\nfunc (d Dump) WriteJSON(w io.Writer) error {\n\tenc := json.NewEncoder(w)\n\tenc.SetIndent(\"\", \"  \")\n\tif err := enc.Encode(d); err != nil {\n\t\treturn fmt.Errorf(\"encode dump: %w\", err)\n\t}\n\treturn nil\n}\n\n// ReadJSON parses a Dump and rejects any version this build can't interpret — a silent misparse of an\n// unrecognized schema is worse than a clear error.\nfunc ReadJSON(r io.Reader) (Dump, error) {\n\tvar d Dump\n\tdec := json.NewDecoder(r)\n\tif err := dec.Decode(&d); err != nil {\n\t\treturn Dump{}, fmt.Errorf(\"decode dump: %w\", err)\n\t}\n\tif d.Version != DumpVersion {\n\t\treturn Dump{}, fmt.Errorf(\"unsupported dump version %q (this build expects %q)\", d.Version, DumpVersion)\n\t}\n\treturn d, nil\n}\n","sourceCodeStart":60,"sourceCodeEnd":85,"githubUrl":"https://github.com/moonD4rk/HackBrowserData/blob/0503d04d7a8d0379d060268a74f1b149e5a0aad5/masterkey/dump.go#L60-L85","documentation":"Dump.ReadJSON parses a Dump from JSON via json.Decoder. This error wraps any decoding failure — malformed JSON, wrong types for fields, or a truncated stream — and deliberately aborts rather than silently misparsing.","triggerScenarios":"Calling ReadJSON with input that is not valid JSON, JSON whose fields don't match Dump's Go types (e.g. version as number instead of string), truncated output from a failed WriteJSON, or extra garbage in the stream.","commonSituations":"Reading a dump file that was hand-edited; reading output from an older/newer tool version with a different schema; a corrupted or partially written dump file; piping the wrong file into ReadJSON.","solutions":["Validate the dump file is well-formed JSON (e.g. with jq) before parsing.","Regenerate the dump with the same version of the tool that reads it.","Check field types match Dump's Go types (notably Version, which is a string compared against DumpVersion).","If the file was truncated, re-run the extraction that produced it."],"exampleFix":"// before\nd, err := ReadJSON(f)\nif err != nil {\n\tlog.Fatalf(\"read dump: %v\", err)\n}\n// after - give the user a clearer diagnosis\nif fi, statErr := f.Stat(); statErr == nil && fi.Size() == 0 {\n\tlog.Fatalf(\"dump file is empty; extraction likely failed\")\n}\nd, err := ReadJSON(f)\nif err != nil {\n\tlog.Fatalf(\"read dump (is it a valid dump file from a matching version?): %v\", err)\n}","handlingStrategy":"validation","validationCode":"var probe struct{ Version string `json:\"version\"` }\nif err := json.Unmarshal(raw, &probe); err != nil {\n\treturn fmt.Errorf(\"file is not a valid dump: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"d, err := masterkey.ReadJSON(f)\nif err != nil {\n\tif strings.Contains(err.Error(), \"decode dump\") {\n\t\tlog.Fatalf(\"input is not a valid dump file: %v\", err)\n\t}\n\treturn err\n}","preventionTips":["Only feed ReadJSON output produced by the same tool version's WriteJSON.","Never hand-edit dump files; regenerate them.","Validate JSON with an external tool (jq) when debugging bad inputs."],"tags":["json","deserialization","dump"],"backgroundTag":"json-unmarshal-failed","analyzedSha":"0503d04d7a8d0379d060268a74f1b149e5a0aad5","analyzedAt":"2026-09-06T13:38:28.707Z","contentChangedAt":"2026-09-06T13:38:28.707Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}