{"record":{"id":"d1c10d7878c293a8","repo":"can1357/oh-my-pi","slug":"lzh-member-memberpath-has-inconsistent-stored","errorCode":null,"errorMessage":"LZH member '${memberPath}' has inconsistent stored size","messagePattern":"LZH member '(.+?)' has inconsistent stored size","errorType":"exception","errorClass":"ArchiveError","httpStatus":null,"severity":"error","filePath":"packages/utils/src/ar/lzh.ts","lineNumber":418,"sourceCode":"\treadonly #method: string;\n\treadonly #crc: number;\n\n\tconstructor(archive: Uint8Array, start: number, packedSize: number, method: string, crc: number) {\n\t\tthis.#archive = archive;\n\t\tthis.#start = start;\n\t\tthis.#packedSize = packedSize;\n\t\tthis.#method = method;\n\t\tthis.#crc = crc;\n\t}\n\n\tasync read(size: number, memberPath: string): Promise<Uint8Array> {\n\t\tconst packed = this.#archive.subarray(this.#start, this.#start + this.#packedSize);\n\t\tlet output: Uint8Array;\n\t\tswitch (this.#method) {\n\t\t\tcase \"-lh0-\":\n\t\t\tcase \"-lz4-\":\n\t\t\t\tif (packed.byteLength !== size)\n\t\t\t\t\tthrow new ArchiveError(`LZH member '${memberPath}' has inconsistent stored size`);\n\t\t\t\toutput = packed.slice();\n\t\t\t\tbreak;\n\t\t\tcase \"-lh4-\":\n\t\t\t\toutput = decompressLhStatic(packed, size, 1 << 12, 4, 13, \"LZH -lh4-\");\n\t\t\t\tbreak;\n\t\t\tcase \"-lh5-\":\n\t\t\t\toutput = decompressLhStatic(packed, size, 1 << 13, 4, 14, \"LZH -lh5-\");\n\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-\":","sourceCodeStart":400,"sourceCodeEnd":436,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/utils/src/ar/lzh.ts#L400-L436","documentation":"For stored (uncompressed) methods -lh0- and -lz4-, the packed data length must exactly equal the declared uncompressed size, since there is no compression to transform it. A mismatch means the header sizes or the data extent are wrong, so the reader throws.","triggerScenarios":"Calling member read/extract on an LZH entry whose method is -lh0- or -lz4- but whose stored packedSize differs from the declared uncompressed size — typically after header corruption, a bad 0x42 64-bit-size override, or truncation of the archive buffer.","commonSituations":"Corrupted or truncated stored archives; archives where extended headers misreport sizes; self-written LZH tooling that writes inconsistent size fields.","solutions":["Re-obtain the archive; for stored members the sizes must match and a mismatch proves corruption","Check whether the file was truncated (compare to expected size/checksum) and re-download","Repack the archive with a standard tool (7-Zip, lha) to regenerate consistent headers","If you write LZH archives, set packedSize === size for -lh0-/-lz4- members"],"exampleFix":"null","handlingStrategy":"validation","validationCode":"// For stored members, packed size must equal declared size\nfunction storedSizeConsistent(packedSize: number, size: number, method: string): boolean {\n\treturn !(method === \"-lh0-\" || method === \"-lz4-\") || packedSize === size;\n}","typeGuard":"function isStoredMethod(method: string): method is \"-lh0-\" | \"-lz4-\" {\n\treturn method === \"-lh0-\" || method === \"-lz4-\";\n}","tryCatchPattern":"try {\n\tconst data = await member.read();\n} catch (err) {\n\tif (err instanceof ArchiveError && err.message.includes(\"inconsistent stored size\")) {\n\t\t// header/data corruption — re-download or repack\n\t}\n\tthrow err;\n}","preventionTips":["Compare archive file size to the sum of member sizes when generating archives","Re-verify downloads against source checksums","Never hand-patch LZH size fields; repack instead"],"tags":["archive","lzh","size-mismatch","corruption"],"backgroundTag":"archive-size-mismatch","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}