kopia/kopia · error
unable to prepare content postamble
Error message
unable to prepare content postamble
What it means
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.
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).
Defensive patterns
Strategy: retry
Try / catch
if err := preparePackDataContent(ctx, mp, pp); err != nil {
if strings.Contains(err.Error(), "postamble") {
// CSPRNG failure: retry pack preparation
}
return err
} Prevention
- Ensure getrandom(2)/dev/urandom is accessible in your sandbox.
- Keep padding unit configuration within supported bounds.
- Retry pack flushes on transient entropy failures.
When it happens
Trigger: 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').
Common situations: Same root causes as random-byte failures: blocked getrandom(2) in sandboxed/seccomp environments or entropy-source issues on the host.
Related errors
- can't initialize randomness
- error getting random bytes
- can't get random bytes
- did not read exactly
- error generating salt
AI-assisted analysis of kopia/kopia@82495e54b5 (2026-09-07).
Data as JSON: /api/errors/6d96ae6adb537631.
Report an issue: GitHub.
Appendix: source
Thrown at repo/content/content_manager_lock_free.go:168
return nil, nil
}
if !haveContent {
// we wrote pack preamble but no actual content, revert it
pp.currentPackData.Reset()
return packFileIndex, nil
}
if pp.finalized {
return packFileIndex, nil
}
pp.finalized = true
if sm.paddingUnit > 0 {
if missing := sm.paddingUnit - (pp.currentPackData.Length() % sm.paddingUnit); missing > 0 {
if err := writeRandomBytesToBuffer(pp.currentPackData, missing); err != nil {
return nil, errors.Wrap(err, "unable to prepare content postamble")
}
}
}
err := sm.appendPackFileIndexRecoveryData(mp, packFileIndex, pp.currentPackData)
return packFileIndex, err
}
func getPackedContentIV(output []byte, contentID ID) []byte {
h := contentID.Hash()
return append(output, h[len(h)-aes.BlockSize:]...)
}
func (sm *SharedManager) writePackFileNotLocked(ctx context.Context, packFile blob.ID, data gather.Bytes, onUpload func(int64)) error {
ctx, span := tracer.Start(ctx, "WritePackFile_"+strings.ToUpper(string(packFile[0:1])), trace.WithAttributes(attribute.String("packFile", string(packFile))))
defer span.End()View on GitHub (pinned to 82495e54b5)