can1357/oh-my-pi · error · ArchiveError
Invalid LZH symbolic link '${header.path}'
Error message
Invalid LZH symbolic link '${header.path}' What it means
A directory entry (-lhd-) whose mode indicates a symlink (S_IFLNK, 0xa000) must encode its link target after a '|' separator in the path ('linkpath|target'). If the path has no '|' or the '|' would start the link name (index < 1), the entry is malformed and cannot be interpreted as a symbolic link.
Source
Thrown at packages/utils/src/ar/lzh.ts:629
}
if (bytes.byteLength !== source.size) throw new ArchiveError("Invalid LZH archive: truncated data");
if (!sniffLzh(bytes)) throw new ArchiveError("Invalid LZH archive header");
const entries: ArchiveIndexEntry[] = [];
let offset = 0;
let parsedCount = 0;
let metadataSize = 0;
while (offset < bytes.byteLength && bytes[offset] !== 0) {
const header = parseLzhHeader(bytes, offset, options);
metadataSize += header.dataStart - offset;
assertIndexSize(metadataSize, options.limits, "index");
assertEntryCount(++parsedCount, options.limits);
if (header.nextOffset <= offset) throw new ArchiveError("Invalid LZH archive: header did not advance");
offset = header.nextOffset;
if (!header.path) continue;
const isDirectory = header.method === "-lhd-";
if (isDirectory && header.mode !== undefined && (header.mode & 0xf000) === 0xa000) {
const separator = header.path.indexOf("|");
if (separator < 1) throw new ArchiveError(`Invalid LZH symbolic link '${header.path}'`);
const path = normalizeArchiveEntryPath(header.path.slice(0, separator));
const targetPath = normalizeArchiveEntryPath(header.path.slice(separator + 1));
if (!path || !targetPath) continue;
entries.push({
path,
isDirectory: false,
size: 0,
mtimeMs: header.mtimeMs,
mode: header.mode,
storage: { type: "link", targetPath, resolveTarget: false },
});
continue;
}
entries.push({
path: header.path,
isDirectory,
size: isDirectory ? 0 : header.size,
mtimeMs: header.mtimeMs,View on GitHub (pinned to 9690622007)
Solutions
- Inspect the offending member with an external LHA tool to see its raw path and mode.
- Recreate the archive with a tool that encodes symlinks as 'linkpath|target' (e.g. modern lha/lhasa on Unix).
- If the entry should be a plain directory, correct its mode (remove the S_IFLNK bits) rather than -lhd- with 0xa000.
- Catch ArchiveError and skip/flag the archive if symlink metadata is not needed.
Example fix
// before: creating a symlink member with the wrong path encoding path = "mylink"; // missing target // after: encode as link|target path = "mylink|/etc/hostname";
Defensive patterns
Strategy: validation
Validate before calling
// pre-screen symlink-style directory entries before reading
// (readLzh throws for -lhd- + S_IFLNK without 'link|target' encoding)
// prefer archives created by tools known to encode symlinks correctly
if (!createdByModernLhaTool(archive)) {
await validateSymlinkEntriesExternally(path); // e.g. `lha l` output check
} Try / catch
try {
const entries = await readLzh(source, options);
} catch (err) {
if (err instanceof ArchiveError && err.message.startsWith("Invalid LZH symbolic link")) {
throw new Error("archive stores symlinks in a non-standard way — repack with lha/lhasa");
}
throw err;
} Prevention
- Create Unix archives with tools that encode symlinks as 'linkpath|target'
- Avoid mixing DOS-era LZH tools with Unix symlink metadata
- Repack legacy archives once with a modern tool and store the result
When it happens
Trigger: readLzh() on an LZH archive containing a -lhd- entry with symlink mode bits but a path missing the 'link|target' separator, e.g. 'foo|' or just 'foo'.
Common situations: Archives produced by tools that store symlinks non-standardly; corrupted path fields; hand-built archives where the symlink encoding convention was not followed.
Related errors
- Invalid CPIO archive: symlink '${recordPath}' has an invalid
- Archive path '${archivePath}' crosses a cyclic symlink
- Invalid ${label} Huffman table: oversubscribed codes
- Invalid ${label} Huffman table: incomplete codes
- Invalid ${label} Huffman table: prefix collision
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/f18b99ee471b35cc.
Report an issue: GitHub.