{"record":{"id":"1beab625ec0039ea","repo":"hashicorp/nomad","slug":"failed-to-decode-snapshot-q-v","errorCode":null,"errorMessage":"failed to decode snapshot %q: %v","messagePattern":"failed to decode snapshot %q: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/operator_snapshot_inspect.go","lineNumber":203,"sourceCode":"\t\tif err != nil {\n\t\t\terrCh <- fmt.Errorf(\"failed to read snapshot: %w\", err)\n\t\t} else {\n\t\t\tmetaCh <- meta\n\t\t}\n\t}()\n\n\thandler := func(header *nomad.SnapshotHeader, snapType nomad.SnapshotType, dec *codec.Decoder) error {\n\t\tname := snapType.String()\n\t\tstat := info.Stats[snapType]\n\n\t\tif stat.Name == \"\" {\n\t\t\tstat.Name = name\n\t\t}\n\n\t\tvar val any\n\t\terr := dec.Decode(&val)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to decode snapshot %q: %v\", snapType, err)\n\t\t}\n\n\t\tsize := cr.read - info.TotalSize\n\t\tstat.Sum += size\n\t\tstat.Count++\n\t\tinfo.TotalSize = cr.read\n\t\tinfo.TotalCount++\n\t\tinfo.Stats[snapType] = stat\n\n\t\treturn nil\n\t}\n\n\terr := nomad.ReadSnapshot(cr, handler)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\tselect {","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/operator_snapshot_inspect.go#L185-L221","documentation":"While streaming entries out of a snapshot archive, each decoded value is read with dec.Decode(&val). If the codec fails to decode an entry of the snapshot (unexpected data layout, truncated section, version mismatch), the inspect handler aborts with this error naming the snapshot type.","triggerScenarios":"The snapshot archive contains an entry whose bytes cannot be decoded into the expected structure — typically a truncated or corrupted snapshot, or a snapshot written by a newer Nomad version with a format the decoding CLI doesn't understand.","commonSituations":"Inspecting snapshots created by a newer Nomad release, snapshots corrupted mid-transfer, or hand-modified snapshot archives.","solutions":["Upgrade the nomad CLI to match (or exceed) the server version that created the snapshot and re-inspect.","Re-take a fresh snapshot with `nomad operator snapshot save` and inspect that instead.","Check snapType in the message to identify which section failed and compare against the wrapped codec error.","Re-download the snapshot if it was transferred over an unreliable channel."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { inspectSnapshot(file) } catch (e) { if (String(e).match(/failed to decode snapshot/)) { console.error('Snapshot entry unreadable; upgrade nomad CLI or retake the snapshot:', e.message); } else { throw e; } }","preventionTips":["Keep the nomad CLI at the same or newer version than the servers that produced the snapshot.","Re-download snapshots that were transferred over unreliable links.","Never hand-edit snapshot archives."],"tags":["codec","snapshot","decoding","nomad"],"backgroundTag":"snapshot-decode-failed","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}