{"record":{"id":"860e7d728c47371a","repo":"can1357/oh-my-pi","slug":"unsupported-xz-filter-id-0x-filter-id-tostring-16","errorCode":null,"errorMessage":"Unsupported XZ filter ID 0x${filter.id.toString(16)}","messagePattern":"Unsupported XZ filter ID 0x(.+?)","errorType":"exception","errorClass":"ArchiveError","httpStatus":null,"severity":"error","filePath":"packages/utils/src/ar/codecs/xz.ts","lineNumber":407,"sourceCode":"\t\t\tia64Decode(bytes, startOffset);\n\t\t\tbreak;\n\t\tcase 7:\n\t\t\tarmDecode(bytes, startOffset);\n\t\t\tbreak;\n\t\tcase 8:\n\t\t\tarmThumbDecode(bytes, startOffset);\n\t\t\tbreak;\n\t\tcase 9:\n\t\t\tsparcDecode(bytes, startOffset);\n\t\t\tbreak;\n\t\tcase 10:\n\t\t\tarm64Decode(bytes, startOffset);\n\t\t\tbreak;\n\t\tcase 11:\n\t\t\triscvDecode(bytes, startOffset);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tthrow new ArchiveError(`Unsupported XZ filter ID 0x${filter.id.toString(16)}`);\n\t}\n}\n\nfunction verifyCheck(checkId: number, output: Uint8Array, expected: Uint8Array): void {\n\tif (checkId === 0) return;\n\tif (checkId === 1) {\n\t\tif (read32LE(expected, 0) !== crc32(output)) throw new ArchiveError(\"Invalid XZ stream: block CRC32 mismatch\");\n\t\treturn;\n\t}\n\tif (checkId === 4) {\n\t\tconst actual = crc64(output);\n\t\tlet stored = 0n;\n\t\tfor (let index = 0; index < 8; index++) stored |= BigInt(expected[index]!) << BigInt(index * 8);\n\t\tif (actual !== stored) throw new ArchiveError(\"Invalid XZ stream: block CRC64 mismatch\");\n\t\treturn;\n\t}\n\tconst actual = new Uint8Array(new Bun.CryptoHasher(\"sha256\").update(output).digest());\n\tif (!equalBytes(actual, expected)) throw new ArchiveError(\"Invalid XZ stream: block SHA-256 mismatch\");","sourceCodeStart":389,"sourceCodeEnd":425,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/utils/src/ar/codecs/xz.ts#L389-L425","documentation":"The XZ block decoder only implements a fixed set of optional filters: Delta (3) and the BCJ family (x86=4, PowerPC=5, IA-64=6, ARM=7/8, SPARC=9, ARM64=10, RISC-V=11). It throws when a block declares a filter ID outside the implemented switch — the stream may be valid XZ but uses a filter this decoder does not support.","triggerScenarios":"Decoding an XZ stream whose block filter list contains an ID not handled by the switch (e.g. a hypothetical future filter, or an ID misread from a corrupt header).","commonSituations":"Files compressed with encoder configurations this pure-TS decoder doesn't implement (exotic filter chains); streams from newer xz versions introducing filters after this code was written; corrupted block headers yielding garbage filter IDs.","solutions":["Re-compress the archive without optional BCJ/Delta filters: `xz --format=xz -z` without --x86 etc., or plain LZMA2 only","Decode the file externally with the reference xz binary and pass uncompressed data to the library","Check if a newer version of this library/package adds support for the filter ID and upgrade","If the input is untrusted, treat unsupported-filter as an expected rejection and inform the user"],"exampleFix":"// before: file compressed with an unsupported BCJ filter chain\n// $ xz --sparc --x86 file.bin\n// after: compress with default settings so blocks use LZMA2 only\n// $ xz -z file.bin","handlingStrategy":"fallback","validationCode":"null","typeGuard":"const SUPPORTED_FILTER_IDS = new Set([3, 4, 5, 6, 8, 10, 11]);\nfunction filtersSupported(ids: number[]): boolean {\n  return ids.every((id) => SUPPORTED_FILTER_IDS.has(id));\n}","tryCatchPattern":"try {\n  return await decodeXz(bytes);\n} catch (err) {\n  if (err instanceof ArchiveError && err.message.startsWith('Unsupported XZ filter ID')) {\n    // fall back to an external, fully-featured xz implementation\n    const out = await $`xz -dc archive.xz`.quiet().nothrow();\n    if (out.exitCode === 0) return new Uint8Array(await out.arrayBuffer());\n  }\n  throw err;\n}","preventionTips":["Prefer plain LZMA2-only compression (no --x86/--arm64 etc.) for data destined for this decoder","Pin encoder and decoder tool versions across your pipeline","For third-party archives, provide an external xz fallback path","Keep this package updated when new XZ filter IDs are standardized"],"tags":["xz","archive","unsupported-feature","filter"],"backgroundTag":"unsupported-codec-feature","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}