can1357/oh-my-pi · error · ArchiveError
Invalid LZMA2 stream: ${error instanceof Error ? error.messa
Error message
Invalid LZMA2 stream: ${error instanceof Error ? error.message : String(error)} What it means
This is the catch-all wrapper for the LZMA2 decode loop: any non-ArchiveError thrown inside the try block (e.g. a range error or internal LZMA decoder failure) is re-thrown as 'Invalid LZMA2 stream: <original message>'. It indicates the input violated LZMA2 framing or the decoder hit an unexpected internal state.
Source
Thrown at packages/utils/src/ar/codecs/lzma.ts:435
const lp = property % 5;
const pb = Math.floor(property / 5);
if (lc + lp > 4) throw new ArchiveError("Invalid LZMA2 literal properties");
decoder.setProperties(lc, lp, pb);
propertiesSet = true;
}
if (packSize > bytes.byteLength - pos || unpackSize > maxOutput - decoder.outputPos)
throw new ArchiveError("Invalid LZMA2 chunk size");
if (resetsDictionary) decoder.resetDictionary();
else if (resetsState) decoder.resetState();
decoder.decodeChunk(bytes.subarray(pos, pos + packSize), unpackSize);
pos += packSize;
needDictionaryReset = false;
}
if (pos !== bytes.byteLength) throw new ArchiveError("Invalid LZMA2 stream: trailing data");
return output.subarray(0, decoder.outputPos);
} catch (error) {
if (error instanceof ArchiveError) throw error;
throw new ArchiveError(`Invalid LZMA2 stream: ${error instanceof Error ? error.message : String(error)}`);
}
}
View on GitHub (pinned to 9690622007)
Solutions
- Read the appended inner message to identify the concrete failure (e.g. bad properties vs range-coder error).
- Verify the input is actually an LZMA2 stream (check container magic for .xz before extracting the payload).
- Re-download or re-extract the archive and verify checksums.
- Confirm no oversized/undersized maxOutput or partial buffer is being passed (see related chunk-size/trailing-data errors).
Example fix
// before: decoding a raw .xz file as LZMA2 lzmaDecompress(xzFileBytes, max); // after: strip the .xz container first, then decode the LZMA2 payload lzmaDecompress(xzPayload, max);
Defensive patterns
Strategy: try-catch
Try / catch
try {
return lzmaDecompress(bytes, maxOutput);
} catch (err) {
if (err instanceof ArchiveError && err.message.startsWith("Invalid LZMA2 stream:")) {
logger.error("LZMA2 decode failed", { detail: err.message }); // inner cause is appended
throw new Error("Unreadable LZMA2 payload — verify format and integrity", { cause: err });
}
throw err;
} Prevention
- Parse the inner message: it names the concrete low-level failure.
- Confirm the payload really is LZMA2 (check .xz magic before extraction).
- Checksum-verify archives from network sources.
- Route all decode failures through one ArchiveError-handling wrapper for consistent reporting.
When it happens
Trigger: Any internal error during lzmaDecompress's decode loop — malformed chunk control bytes, bad literal properties, dictionary/range-coder faults, or out-of-bounds subarray reads — surfaces with the inner error's message appended.
Common situations: Corrupted .xz/.lzma payloads; wrong dictionary/reset flags from a mangled control byte; decoding a file that isn't LZMA2 at all (wrong magic, wrong format); version mismatch between encoder features and decoder.
Related errors
- Invalid LZMA2 stream: trailing data
- Invalid LZMA2 chunk size
- Invalid non-zero compress (.Z) padding
- Invalid RAR archive: ${reason}
- archive destination exists: ${destSession}
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/439fd8f4a1f3b948.
Report an issue: GitHub.