{"record":{"id":"52d9fde45d9f9b10","repo":"hashicorp/nomad","slug":"file-missing-for-q","errorCode":null,"errorMessage":"file missing for %q","messagePattern":"file missing for %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"helper/snapshot/archive.go","lineNumber":92,"sourceCode":"\t\t}\n\n\t\th, ok := hl.hashes[file]\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"list missing hash for %q\", file)\n\t\t}\n\t\tif !bytes.Equal(sha, h.Sum([]byte{})) {\n\t\t\treturn fmt.Errorf(\"hash check failed for %q\", file)\n\t\t}\n\t\tseen[file] = struct{}{}\n\t}\n\tif err := s.Err(); err != nil {\n\t\treturn err\n\t}\n\n\t// Make sure everything we had a hash for was seen.\n\tfor file := range hl.hashes {\n\t\tif _, ok := seen[file]; !ok {\n\t\t\treturn fmt.Errorf(\"file missing for %q\", file)\n\t\t}\n\t}\n\n\treturn nil\n}\n\n// write takes a writer and creates an archive with the snapshot metadata,\n// the snapshot itself, and adds some integrity checking information.\nfunc write(out io.Writer, metadata *raft.SnapshotMeta, snap io.Reader) error {\n\t// Start a new tarball.\n\tnow := time.Now()\n\tarchive := tar.NewWriter(out)\n\n\t// Create a hash list that we will use to write a SHA256SUMS file into\n\t// the archive.\n\thl := newHashList()\n\n\t// Encode the snapshot metadata, which we need to feed back during a","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/helper/snapshot/archive.go#L74-L110","documentation":"After iterating all archive entries, DecodeAndVerify checks that every file that had a hash in the SHA256SUMS listing was actually seen in the archive. This error means an expected entry (meta.json, state.bin, or SHA256SUMS itself) is absent from the tar. It guards against incomplete or truncated archives.","triggerScenarios":"The tar writer failed to emit an entry, an entry was removed from the archive, or an entry's mis-set Size swallowed the next entry so it never appears as a separate tar header.","commonSituations":"A partially written snapshot (crash mid-write), manual extraction/repacking that dropped meta.json, or a corrupted tar stream where sizes drifted and headers were consumed as data.","solutions":["Recreate the snapshot with write() to regenerate all three entries (meta.json, state.bin, SHA256SUMS)","Inspect the archive listing (tar -tf) to confirm which entry is missing","Ensure no entry Size overrides consumed subsequent headers","Restore from a known-good backup of the snapshot"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"names, err := tarEntryNames(snapshotPath)\nif err != nil {\n    return err\n}\nfor _, want := range []string{\"meta.json\", \"state.bin\", \"SHA256SUMS\"} {\n    if !slices.Contains(names, want) {\n        return fmt.Errorf(\"snapshot missing %s\", want)\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := snapshot.DecodeAndVerify(w, r, size); err != nil {\n    if strings.Contains(err.Error(), \"file missing for\") {\n        return fmt.Errorf(\"incomplete snapshot: %w\", err)\n    }\n    return err\n}","preventionTips":["Check archive completeness (tar -tf) before restore","Only consume snapshots produced atomically by write()","Reject snapshots from interrupted writes"],"tags":["integrity","missing-file","snapshot"],"backgroundTag":"archive-entry-missing","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"}