{"record":{"id":"cf28f3d27eaf8d06","repo":"Yeachan-Heo/oh-my-codex","slug":"archive-inspection-failed","errorCode":"archive_inspection_failed","errorMessage":"[native-assets] archive_inspection_failed: invalid entry size: ${rawName}","messagePattern":"\\[native-assets\\] archive_inspection_failed: invalid entry size: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/native-assets/archive.ts","lineNumber":39,"sourceCode":"  /** @deprecated Use normalizedName. */\n  path: string;\n  type: NativeArchiveEntryType;\n  size: number;\n}\n\nfunction archiveError(code: string, detail: string): Error {\n  return new Error(`[native-assets] ${code}: ${detail}`);\n}\n\nfunction archiveFormat(archivePath: string): 'tar.xz' | 'tar.gz' | 'zip' {\n  if (/\\.tar\\.xz$/i.test(archivePath)) return 'tar.xz';\n  if (/\\.tar\\.gz$/i.test(archivePath)) return 'tar.gz';\n  if (/\\.zip$/i.test(archivePath)) return 'zip';\n  throw archiveError('archive_format_unsupported', archivePath);\n}\n\nfunction entry(rawName: string, type: NativeArchiveEntryType, size: number): NativeArchiveEntry {\n  if (!Number.isSafeInteger(size) || size < 0) throw archiveError('archive_inspection_failed', `invalid entry size: ${rawName}`);\n  const normalizedName = normalizeNativeArchivePath(rawName, type);\n  return { rawName, normalizedName, path: normalizedName, type, size };\n}\n\nasync function tarInput(archivePath: string, format: 'tar.xz' | 'tar.gz'): Promise<Readable> {\n  try {\n    const archive = readFileSync(archivePath);\n    return Readable.from(format === 'tar.gz' ? gunzipSync(archive) : await decompress(archive));\n  } catch (error) {\n    throw archiveError('archive_inspection_failed', error instanceof Error ? error.message : archivePath);\n  }\n}\n\nasync function inspectTar(archivePath: string, format: 'tar.xz' | 'tar.gz'): Promise<NativeArchiveEntry[]> {\n  const entries: NativeArchiveEntry[] = [];\n  const extractor = tar.extract();\n  extractor.on('entry', (header, source, next) => {\n    try {","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/Yeachan-Heo/oh-my-codex/blob/3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2/src/native-assets/archive.ts#L21-L57","documentation":"While listing archive entries, the inspector parses each entry's size and rejects values that are not safe non-negative integers (NaN, fractional, negative, or beyond Number.MAX_SAFE_INTEGER) by throwing archive_inspection_failed with 'invalid entry size'. This almost always indicates a corrupt or maliciously crafted archive whose header metadata is garbage.","triggerScenarios":"inspectTar/inspectZip encountering an entry whose declared size in the tar/zip header fails Number.isSafeInteger(size) || size < 0 — truncated archives, headers overwritten, or adversarial zip-bomb-style metadata.","commonSituations":"Truncated downloads (interrupted fetch of a release artifact); archives corrupted in transit or by storage; hand-crafted/modified archives; cross-generator archives writing 64-bit sizes that overflow when parsed incorrectly.","solutions":["Re-download or regenerate the archive from a trusted source and verify its checksum before inspecting","Validate the archive with an external tool (tar -t, unzip -l) to confirm the corruption","If accepting user-supplied archives, pre-scan and reject malformed ones before calling the inspector","Report upstream if the archive opens fine in other tools (possible parser bug)"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Verify integrity before inspecting\nimport { createHash } from 'node:crypto';\nconst actual = createHash('sha256').update(await readFile(archivePath)).digest('hex');\nif (actual !== expectedSha256) throw new Error('archive checksum mismatch');","typeGuard":"function isArchiveInspectionFailure(e: unknown): e is { code: 'archive_inspection_failed' } {\n  return (e as { code?: string })?.code === 'archive_inspection_failed';\n}","tryCatchPattern":"catch (e) {\n  if (isArchiveInspectionFailure(e)) {\n    // reject the input; do not retry — the archive bytes are bad\n    quarantine(archivePath);\n  } else throw e;\n}","preventionTips":["Checksum-verify downloads before inspection","Reject user-supplied archives that fail external listing (tar -t / unzip -l)","Treat invalid entry sizes as corruption and re-fetch from a trusted source"],"tags":["native-assets","archive","corruption","validation"],"backgroundTag":"corrupt-archive-file","analyzedSha":"3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2","analyzedAt":"2026-08-27T22:18:39.783Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}