{"record":{"id":"b1f69e4f9b0c0df3","repo":"can1357/oh-my-pi","slug":"lzh-member-memberpath-uses-unsupported-dynami","errorCode":null,"errorMessage":"LZH member '${memberPath}' uses unsupported dynamic-Huffman method -lh1-","messagePattern":"LZH member '(.+?)' uses unsupported dynamic-Huffman method -lh1-","errorType":"exception","errorClass":"ArchiveError","httpStatus":null,"severity":"error","filePath":"packages/utils/src/ar/lzh.ts","lineNumber":437,"sourceCode":"\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-\":\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;","sourceCodeStart":419,"sourceCodeEnd":455,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/utils/src/ar/lzh.ts#L419-L455","documentation":"-lh1- uses dynamic Huffman tables (the older LZHUF scheme), which this decoder does not implement; it only supports the static-Huffman -lh4-..-lh7- methods plus stored/-lzs-. Members compressed with -lh1- are rejected explicitly.","triggerScenarios":"Reading an LZH archive whose member was compressed with method -lh1- (common in very old LHA files and the original LHarc output) and then extracting/reading that member.","commonSituations":"Opening 1990s-era LHA archives; files created by legacy LHarc 1.x; migrating old Japanese software distributions that used -lh1-.","solutions":["Recompress the archive with a modern tool (e.g. `lha a -lh5` or 7-Zip) so members use -lh5-/-lh6-/-lh7-, then read the repacked archive","Extract -lh1- members with an external tool that supports them (lhasa, UNLHA32, The Unarchiver) and feed the extracted files to your app instead","Detect the method before extraction (method bytes at header offset+2) and warn users about legacy -lh1- content","If -lh1- support is essential for your use case, file an issue/request on the library"],"exampleFix":"// before\nconst entries = await readArchive(lzhBytes); // throws on -lh1- members\n// after\nimport { sniffLzh } from \"@oh-my-pi/pi-utils/ar/lzh\";\nconst method = String.fromCharCode(...lzhBytes.subarray(2, 7));\nif (method === \"-lh1-\") {\n\tconst entries = await repackWithModernTool(lzhBytes); // e.g. lha -> -lh5-\n\treturn readArchive(entries);\n}\nreturn readArchive(lzhBytes);","handlingStrategy":"fallback","validationCode":"// Inspect the method bytes of the first member before reading\nfunction lzhMethod(bytes: Uint8Array): string {\n\treturn String.fromCharCode(...bytes.subarray(2, 7));\n}","typeGuard":"function isUnsupportedDynamicMethod(method: string): boolean {\n\treturn method === \"-lh1-\" || method === \"-lh2-\" || method === \"-lh3-\";\n}","tryCatchPattern":"try {\n\treturn await readArchive(lzhBytes);\n} catch (err) {\n\tif (err instanceof ArchiveError && err.message.includes(\"-lh1-\")) {\n\t\t// fallback: recompress/extract externally, then retry\n\t\tconst repacked = await repackWithExternalTool(lzhBytes);\n\t\treturn readArchive(repacked);\n\t}\n\tthrow err;\n}","preventionTips":["Normalize legacy archives: recompress -lh1- content to -lh5-+ before ingestion","Flag old LHarc-era files during intake","Prefer zip/tar for new archives; keep LZH only for compatibility reads"],"tags":["archive","lzh","unsupported-compression","lh1"],"backgroundTag":"unsupported-compression-method","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}