oven-sh/bun · error · Error
Lockfile is malformed (expected 0 at the end)
Error message
Lockfile is malformed (expected 0 at the end)
What it means
The binary/text lockfile payload does not end with the expected 0 terminator byte, indicating truncation or corruption of the serialized stream. It fires during validation of the lockfile byte format before parsing offsets.
Solutions
- Regenerate the lockfile with a fresh `bun install`
- Restore bun.lock from version control if it was truncated
- Ensure no tool partially rewrites bun.lock concurrently
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at src/install/error.rs:173 when the library encounters an invalid state.
Common situations: See trigger scenarios.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
AI-assisted analysis of oven-sh/bun@8c5296ac45 (2026-08-16).
Data as JSON: /api/errors/bc28cc6ae6a8ceae.
Report an issue: GitHub.
Appendix: source
Thrown at src/install/error.rs:173
#[error("DebugTextLockfileRoundTrip")]
DebugTextLockfileRoundTrip,
#[error("NoPackage")]
NoPackage,
#[error("BrokenPipe")]
BrokenPipe,
#[error("WriteFailed")]
WriteFailed,
#[error("InvalidCharacter")]
InvalidCharacter,
#[error("InvalidLockfile")]
InvalidLockfile,
#[error("Unexpected lockfile version")]
UnexpectedLockfileVersion,
#[error("Outdated lockfile version")]
OutdatedLockfileVersion,
#[error("Lockfile is missing data")]
LockfileIsMissingData,
#[error("Lockfile is malformed (expected 0 at the end)")]
LockfileIsMalformedExpected0AtTheEnd,
#[error("CorruptLockfile")]
CorruptLockfile,
#[error("Lockfile is missing resolution data")]
LockfileIsMissingResolutionData,
#[error("MissingPackageName")]
MissingPackageName,
#[error("GlobError")]
GlobError,
#[error("Invalid")]
Invalid,
#[error("Lockfile validation failed: list is impossibly long")]
LockfileValidationFailedListIsImpossiblyLong,
#[error("Lockfile validation failed: alignment mismatch")]
LockfileValidationFailedAlignmentMismatch,
#[error("Lockfile validation failed: unexpected number of package fields")]
LockfileValidationFailedUnexpectedNumberOfPackageFields,
#[error("Lockfile validation failed: invalid package list range")]View on GitHub (pinned to 8c5296ac45)