moonD4rk/HackBrowserData · error

decode dump: %w

Error message

decode dump: %w

What it means

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.

Source

Thrown at masterkey/dump.go:78

	return h
}

func (d Dump) WriteJSON(w io.Writer) error {
	enc := json.NewEncoder(w)
	enc.SetIndent("", "  ")
	if err := enc.Encode(d); err != nil {
		return fmt.Errorf("encode dump: %w", err)
	}
	return nil
}

// ReadJSON parses a Dump and rejects any version this build can't interpret — a silent misparse of an
// unrecognized schema is worse than a clear error.
func ReadJSON(r io.Reader) (Dump, error) {
	var d Dump
	dec := json.NewDecoder(r)
	if err := dec.Decode(&d); err != nil {
		return Dump{}, fmt.Errorf("decode dump: %w", err)
	}
	if d.Version != DumpVersion {
		return Dump{}, fmt.Errorf("unsupported dump version %q (this build expects %q)", d.Version, DumpVersion)
	}
	return d, nil
}

View on GitHub (pinned to 0503d04d7a)

Solutions

  1. Validate the dump file is well-formed JSON (e.g. with jq) before parsing.
  2. Regenerate the dump with the same version of the tool that reads it.
  3. Check field types match Dump's Go types (notably Version, which is a string compared against DumpVersion).
  4. If the file was truncated, re-run the extraction that produced it.

Example fix

// before
d, err := ReadJSON(f)
if err != nil {
	log.Fatalf("read dump: %v", err)
}
// after - give the user a clearer diagnosis
if fi, statErr := f.Stat(); statErr == nil && fi.Size() == 0 {
	log.Fatalf("dump file is empty; extraction likely failed")
}
d, err := ReadJSON(f)
if err != nil {
	log.Fatalf("read dump (is it a valid dump file from a matching version?): %v", err)
}
Defensive patterns

Strategy: validation

Validate before calling

var probe struct{ Version string `json:"version"` }
if err := json.Unmarshal(raw, &probe); err != nil {
	return fmt.Errorf("file is not a valid dump: %w", err)
}

Try / catch

d, err := masterkey.ReadJSON(f)
if err != nil {
	if strings.Contains(err.Error(), "decode dump") {
		log.Fatalf("input is not a valid dump file: %v", err)
	}
	return err
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "failed to unmarshal" / json.Unmarshal errors: why parsing a response into a Go struct fails and how to fix it — this error's family across 23 libraries.

Related errors


AI-assisted analysis of moonD4rk/HackBrowserData@0503d04d7a (2026-09-06). Data as JSON: /api/errors/1c63664a4ac24a64. Report an issue: GitHub.