{"record":{"id":"aa7ec050ce6a1235","repo":"can1357/oh-my-pi","slug":"invalid-zip-archive-crc-mismatch-for-memberpat","errorCode":null,"errorMessage":"Invalid ZIP archive: CRC mismatch for '${memberPath}'","messagePattern":"Invalid ZIP archive: CRC mismatch for '(.+?)'","errorType":"exception","errorClass":"ArchiveError","httpStatus":null,"severity":"error","filePath":"packages/utils/src/ar/zip.ts","lineNumber":436,"sourceCode":"\t\t\tconst dataEnd = checkedEnd(dataStart, this.#compressedSize, this.#source.size, `data for '${memberPath}'`);\n\t\t\tif (this.#method === 0 && this.#compressedSize !== size) {\n\t\t\t\tthrow new ArchiveError(\n\t\t\t\t\t`Invalid ZIP archive: size mismatch for '${memberPath}' (expected ${size}, got ${this.#compressedSize})`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst compressed = await this.#source.read(dataStart, dataEnd);\n\t\t\tif (compressed.byteLength !== this.#compressedSize) {\n\t\t\t\tthrow new ArchiveError(`Invalid ZIP archive: truncated data for '${memberPath}'`);\n\t\t\t}\n\t\t\tconst decoded = await decodeMember(compressed, this.#method, size, memberPath);\n\t\t\tif (decoded.byteLength !== size) {\n\t\t\t\tthrow new ArchiveError(\n\t\t\t\t\t`Invalid ZIP archive: size mismatch for '${memberPath}' (expected ${size}, got ${decoded.byteLength})`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst actualCrc = crc32(decoded);\n\t\t\tif (actualCrc !== this.#crc) {\n\t\t\t\tthrow new ArchiveError(`Invalid ZIP archive: CRC mismatch for '${memberPath}'`);\n\t\t\t}\n\t\t\treturn decoded;\n\t\t} catch (error) {\n\t\t\tthrow archiveError(error, `Failed to read ZIP member '${memberPath}'`);\n\t\t}\n\t}\n}\n\nfunction parseCentralDirectory(\n\tsource: ByteSource,\n\tdirectory: Uint8Array,\n\tinfo: CentralDirectoryInfo,\n\toptions: FormatReadOptions,\n): ParsedZipEntry[] {\n\tconst parsed: ParsedZipEntry[] = [];\n\tlet offset = 0;\n\tfor (let index = 0; index < info.entries; index++) {\n\t\tif (offset + 46 > directory.byteLength)","sourceCodeStart":418,"sourceCodeEnd":454,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/utils/src/ar/zip.ts#L418-L454","documentation":"Thrown when the CRC-32 of the decoded member bytes does not match the CRC stored in the central directory. The member decompressed to the right size but with wrong content — silent data corruption. The library refuses to return corrupt data. ArchiveError naming the member.","triggerScenarios":"ZipMemberSource read where crc32(decoded) !== this.#crc after size checks pass — bit corruption in the compressed data, wrong-content substitution, or an archive whose CRC field was patched without recompressing.","commonSituations":"Failing disks or bad RAM corrupting stored archives; network transfers without integrity checking; zips stored on damaged media; archives edited by tools that update sizes but not CRCs.","solutions":["Re-obtain the archive and verify a published checksum (SHA-256) before use","Run `unzip -t` to confirm corruption and identify affected members","Re-zip from the original source files to regenerate correct CRCs","Check storage health (fsck/SMART) if corruption recurs on locally stored archives"],"exampleFix":"// before\nconst data = await readZipMember(zip, 'report.pdf'); // throws 3717\n// after: verify archive integrity first, then re-fetch if bad\n// $ `unzip -t archive.zip || re-download`\nconst data = await readZipMember(zip, 'report.pdf');","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const data = await zip.read(member);\n} catch (err) {\n  if (err instanceof ArchiveError && err.message.includes('CRC mismatch')) {\n    // re-download or re-zip; log the member name for telemetry\n    throw new Error(`data corruption detected in ${member}; refetch archive`);\n  }\n  throw err;\n}","preventionTips":["Verify a publisher checksum (SHA-256) before extracting archives","Run `unzip -t` on archives stored long-term before use","Monitor storage health if CRC errors recur (SMART, fsck, memtest)","Never accept CRC-mismatched members for correctness-critical data"],"tags":["zip","crc-mismatch","data-corruption","integrity-check"],"backgroundTag":"zip-crc-mismatch","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}