{"record":{"id":"bab135ad2dc987b8","repo":"hashicorp/nomad","slug":"failed-to-write-snapshot-hashes-header-v","errorCode":null,"errorMessage":"failed to write snapshot hashes header: %v","messagePattern":"failed to write snapshot hashes header: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"helper/snapshot/archive.go","lineNumber":155,"sourceCode":"\t}); err != nil {\n\t\treturn fmt.Errorf(\"failed to write snapshot data header: %v\", err)\n\t}\n\tif _, err := io.CopyN(archive, io.TeeReader(snap, snapHash), metadata.Size); err != nil {\n\t\treturn fmt.Errorf(\"failed to write snapshot metadata: %v\", err)\n\t}\n\n\t// Create a SHA256SUMS file that we can use to verify on restore.\n\tvar shaBuffer bytes.Buffer\n\tif err := hl.Encode(&shaBuffer); err != nil {\n\t\treturn fmt.Errorf(\"failed to encode snapshot hashes: %v\", err)\n\t}\n\tif err := archive.WriteHeader(&tar.Header{\n\t\tName:    \"SHA256SUMS\",\n\t\tMode:    0600,\n\t\tSize:    int64(shaBuffer.Len()),\n\t\tModTime: now,\n\t}); err != nil {\n\t\treturn fmt.Errorf(\"failed to write snapshot hashes header: %v\", err)\n\t}\n\tif _, err := io.Copy(archive, &shaBuffer); err != nil {\n\t\treturn fmt.Errorf(\"failed to write snapshot metadata: %v\", err)\n\t}\n\n\t// Finalize the archive.\n\tif err := archive.Close(); err != nil {\n\t\treturn fmt.Errorf(\"failed to finalize snapshot: %v\", err)\n\t}\n\n\treturn nil\n}\n\n// read takes a reader and extracts the snapshot metadata and the snapshot\n// itself, and also checks the integrity of the data. You must arrange to call\n// Close() on the returned object or else you will leak a temporary file.\nfunc read(in io.Reader, metadata *raft.SnapshotMeta, snap io.Writer) error {\n\t// Start a new tar reader.","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/helper/snapshot/archive.go#L137-L173","documentation":"write() adds the SHA256SUMS tar header sized to the encoded hash listing. This error wraps a failure writing that header to the archive sink. It indicates the destination writer failed while emitting the final entry's header.","triggerScenarios":"archive.WriteHeader for SHA256SUMS fails because the underlying writer errors: disk full, closed writer, or broken network stream.","commonSituations":"Destination storage exhausted near the end of a large snapshot; sink connection dropped.","solutions":["Free destination disk space before writing snapshots","Verify the sink writer stays open through archive.Close()","Inspect the wrapped error for the concrete cause"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"free, _ := diskFree(destPath)\nif free < estimatedSnapshotSize+4096 {\n    return errors.New(\"insufficient space\")\n}","typeGuard":null,"tryCatchPattern":"if err := write(archive, metadata, snap); err != nil {\n    if strings.Contains(err.Error(), \"failed to write snapshot hashes header\") {\n        return fmt.Errorf(\"archive sink failed: %w\", err)\n    }\n    return err\n}","preventionTips":["Reserve space for all four entries (meta.json, state.bin, SHA256SUMS, padding)","Hold the sink open for the whole write","Check archive.Close() errors too"],"tags":["tar","io","disk"],"backgroundTag":"disk-full","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"}