{"record":{"id":"2592bbcce16be9cc","repo":"oven-sh/bun","slug":"wrong-first-byte","errorCode":null,"errorMessage":"Wrong first byte","messagePattern":"Wrong first byte","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"bench/snippets/buffer-concat.mjs","lineNumber":30,"sourceCode":"\n  const buffers = [first, second, third];\n\n  const fmt =\n    size > 1024 * 1024\n      ? new Intl.NumberFormat(undefined, { unit: \"megabyte\", style: \"unit\" })\n      : size > 1024\n        ? new Intl.NumberFormat(undefined, { unit: \"kilobyte\", style: \"unit\" })\n        : new Intl.NumberFormat(undefined, { unit: \"byte\", style: \"unit\" });\n\n  bench(\n    `Buffer.concat(${fmt.format(\n      Number((size > 1024 * 1024 ? size / 1024 / 1024 : size > 1024 ? size / 1024 : size).toFixed(2)),\n    )} x 3)`,\n    () => {\n      const result = Buffer.concat(buffers);\n      if (check) {\n        if (result.byteLength != size * 3) throw new Error(\"Wrong length\");\n        if (result[0] != 1) throw new Error(\"Wrong first byte\");\n        if (result[size] != 2) throw new Error(\"Wrong second byte\");\n        if (result[size * 2] != 3) throw new Error(\"Wrong third byte\");\n\n        result[0] = 10;\n        if (first[0] != 1) throw new Error(\"First buffer was modified\");\n\n        result[size] = 20;\n        if (second[0] != 2) throw new Error(\"Second buffer was modified\");\n\n        result[size * 2] = 30;\n        if (third[0] != 3) throw new Error(\"Third buffer was modified\");\n      }\n    },\n  );\n}\n\nconst chunk = Buffer.alloc(16);\nchunk.fill(\"3\");","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/oven-sh/bun/blob/8c5296ac459e8252d3cd702f3fbcbb0c249d95d5/bench/snippets/buffer-concat.mjs#L12-L48","documentation":"Validation of the binary lockfile's package section rejected the list length header: it exceeds u32::MAX - 1, an impossible package count (src/install/lockfile/Package.rs:3191-3193). The check exists to refuse absurd allocations before trusting the header.","triggerScenarios":"A bun.lockb whose length field is random/garbage bytes - e.g. a non-lockfile file at that path, severe corruption, or a file mangled in transfer.","commonSituations":"Binary merge damage, wrong file committed as bun.lockb, storage corruption.","solutions":["Restore bun.lockb from git","Otherwise delete it and run `bun install` to regenerate"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never commit a non-lockfile file as bun.lockb","Restore or regenerate on any corruption-class failure","Keep bun.lockb out of text-processing pipelines"],"tags":["lockfile","corruption","validation"],"backgroundTag":null,"analyzedSha":"8c5296ac459e8252d3cd702f3fbcbb0c249d95d5","analyzedAt":"2026-08-16T08:01:58.794Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}