{"record":{"id":"76e4d38966069070","repo":"can1357/oh-my-pi","slug":"lzh-member-memberpath-failed-crc-16-verificat","errorCode":null,"errorMessage":"LZH member '${memberPath}' failed CRC-16 verification","messagePattern":"LZH member '(.+?)' failed CRC-16 verification","errorType":"exception","errorClass":"ArchiveError","httpStatus":null,"severity":"error","filePath":"packages/utils/src/ar/lzh.ts","lineNumber":444,"sourceCode":"\t\t\t\tbreak;\n\t\t\tcase \"-lh6-\":\n\t\t\t\toutput = decompressLhStatic(packed, size, 1 << 15, 5, 16, \"LZH -lh6-\");\n\t\t\t\tbreak;\n\t\t\tcase \"-lh7-\":\n\t\t\t\toutput = decompressLhStatic(packed, size, 1 << 16, 5, 17, \"LZH -lh7-\");\n\t\t\t\tbreak;\n\t\t\tcase \"-lzs-\":\n\t\t\t\toutput = decompressLzs(packed, size);\n\t\t\t\tbreak;\n\t\t\tcase \"-lh1-\":\n\t\t\t\tthrow new ArchiveError(`LZH member '${memberPath}' uses unsupported dynamic-Huffman method -lh1-`);\n\t\t\tdefault:\n\t\t\t\tthrow new ArchiveError(`LZH member '${memberPath}' uses unsupported compression method ${this.#method}`);\n\t\t}\n\t\tif (output.byteLength !== size)\n\t\t\tthrow new ArchiveError(`LZH member '${memberPath}' extracted to an unexpected size`);\n\t\tif (crc16Arc(output) !== this.#crc)\n\t\t\tthrow new ArchiveError(`LZH member '${memberPath}' failed CRC-16 verification`);\n\t\treturn output;\n\t}\n}\n\ninterface ParsedLzhHeader {\n\tmethod: string;\n\tpackedSize: number;\n\tsize: number;\n\tdataStart: number;\n\tnextOffset: number;\n\tcrc: number;\n\tpath?: string;\n\tmtimeMs?: number;\n\tmode?: number;\n}\n\nfunction parseLzhHeader(bytes: Uint8Array, offset: number, options: FormatReadOptions): ParsedLzhHeader {\n\tassertRange(bytes, offset, offset + 22, \"header\");","sourceCodeStart":426,"sourceCodeEnd":462,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/utils/src/ar/lzh.ts#L426-L462","documentation":"Thrown by the LZH member extractor after decompression when the CRC-16 of the produced output does not match the CRC stored in the member's header. It means the archive bytes are corrupt, truncated, or the decompressor produced wrong output. The library verifies integrity before returning extracted data, so data is never silently wrong.","triggerScenarios":"Calling the LZH reader's member-extraction API on an archive whose compressed payload was corrupted in transit or on disk, or a member whose header CRC field does not match the actual data (hand-edited or badly written archives).","commonSituations":"Downloads that were truncated or corrupted, archives stored on failing media, archives created by non-conforming LZH writers that compute CRC differently, or byte-level tampering.","solutions":["Re-download or re-extract the archive from a trusted source and verify its checksum","Repack the archive with a conforming LHA tool (e.g. lha) to regenerate a correct CRC","Confirm the source file is not being read truncated (check file size and read stream completion)","If you control the writer, ensure it computes the standard ARC CRC-16 over the raw member data"],"exampleFix":"// before: blindly reusing a partially downloaded archive\nconst bytes = await partialRead(url);\nconst archive = LzhReader.read(bytes);\n// after: verify completeness first\nconst bytes = new Uint8Array(await Bun.file(path).arrayBuffer());\nif (bytes.byteLength < expectedSize) throw new Error('incomplete archive');\nconst archive = LzhReader.read(bytes);","handlingStrategy":"try-catch","validationCode":"if (!(await Bun.file(path).exists())) throw new Error('archive missing');","typeGuard":null,"tryCatchPattern":"try { extract(); } catch (err) { if (err instanceof ArchiveError) report(err.message); else throw err; }","preventionTips":["Always transfer archives with checksum verification","Never resume-merge partial downloads of archives"],"tags":["archive","lzh","crc","data-integrity","corruption"],"backgroundTag":"archive-crc-mismatch","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}