{"record":{"id":"6d96ae6adb537631","repo":"kopia/kopia","slug":"unable-to-prepare-content-postamble","errorCode":null,"errorMessage":"unable to prepare content postamble","messagePattern":"unable to prepare content postamble","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"repo/content/content_manager_lock_free.go","lineNumber":168,"sourceCode":"\t\treturn nil, nil\n\t}\n\n\tif !haveContent {\n\t\t// we wrote pack preamble but no actual content, revert it\n\t\tpp.currentPackData.Reset()\n\t\treturn packFileIndex, nil\n\t}\n\n\tif pp.finalized {\n\t\treturn packFileIndex, nil\n\t}\n\n\tpp.finalized = true\n\n\tif sm.paddingUnit > 0 {\n\t\tif missing := sm.paddingUnit - (pp.currentPackData.Length() % sm.paddingUnit); missing > 0 {\n\t\t\tif err := writeRandomBytesToBuffer(pp.currentPackData, missing); err != nil {\n\t\t\t\treturn nil, errors.Wrap(err, \"unable to prepare content postamble\")\n\t\t\t}\n\t\t}\n\t}\n\n\terr := sm.appendPackFileIndexRecoveryData(mp, packFileIndex, pp.currentPackData)\n\n\treturn packFileIndex, err\n}\n\nfunc getPackedContentIV(output []byte, contentID ID) []byte {\n\th := contentID.Hash()\n\n\treturn append(output, h[len(h)-aes.BlockSize:]...)\n}\n\nfunc (sm *SharedManager) writePackFileNotLocked(ctx context.Context, packFile blob.ID, data gather.Bytes, onUpload func(int64)) error {\n\tctx, span := tracer.Start(ctx, \"WritePackFile_\"+strings.ToUpper(string(packFile[0:1])), trace.WithAttributes(attribute.String(\"packFile\", string(packFile))))\n\tdefer span.End()","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/kopia/kopia/blob/82495e54b584c1ef6073c9e1be048f57f8aef078/repo/content/content_manager_lock_free.go#L150-L186","documentation":"Wraps writeRandomBytesToBuffer errors raised while padding the pack with random bytes up to the padding unit before finalizing it. The pack cannot be finalized without the postamble padding, so pack preparation fails.","triggerScenarios":"preparePackDataContent (called by prepareAndWritePackInternal) with sm.paddingUnit > 0 where writeRandomBytesToBuffer fails while appending `sm.paddingUnit - (length % paddingUnit)` random bytes — i.e. the CSPRNG read failed (see 'error getting random bytes').","commonSituations":"Same root causes as random-byte failures: blocked getrandom(2) in sandboxed/seccomp environments or entropy-source issues on the host.","solutions":["Retry the pack write; transient CSPRNG failures usually resolve.","Fix the sandbox/seccomp or container profile so getrandom(2)/dev/urandom is reachable.","Check host entropy configuration (e.g. haveged/rngd on VMs with poor entropy)."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := preparePackDataContent(ctx, mp, pp); err != nil {\n    if strings.Contains(err.Error(), \"postamble\") {\n        // CSPRNG failure: retry pack preparation\n    }\n    return err\n}","preventionTips":["Ensure getrandom(2)/dev/urandom is accessible in your sandbox.","Keep padding unit configuration within supported bounds.","Retry pack flushes on transient entropy failures."],"tags":["randomness","padding","entropy"],"backgroundTag":"random-bytes-generation-failed","analyzedSha":"82495e54b584c1ef6073c9e1be048f57f8aef078","analyzedAt":"2026-09-07T20:35:21.689Z","contentChangedAt":"2026-09-07T20:35:21.689Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}