{"record":{"id":"10e4156183b2cde1","repo":"can1357/oh-my-pi","slug":"invalid-tar-field","errorCode":null,"errorMessage":"Invalid tar ${field}","messagePattern":"Invalid tar (.+?)","errorType":"exception","errorClass":"ArchiveError","httpStatus":null,"severity":"error","filePath":"packages/utils/src/ar/tar.ts","lineNumber":148,"sourceCode":"\t}\n\treturn Number(value);\n}\n\nfunction readTarSize(buffer: Uint8Array, offset: number): number {\n\tconst size = readTarNumeric(buffer, offset, SIZE_LENGTH);\n\tif (!Number.isSafeInteger(size) || size < 0) throw new ArchiveError(\"Invalid tar member size\");\n\treturn size;\n}\n\nfunction paddedSize(size: number): number {\n\tconst remainder = size % BLOCK_SIZE;\n\tconst padded = size + (remainder === 0 ? 0 : BLOCK_SIZE - remainder);\n\tif (!Number.isSafeInteger(padded)) throw new ArchiveError(\"Invalid tar member size\");\n\treturn padded;\n}\n\nfunction parsePaxSize(value: string, field: string): number {\n\tif (!/^\\d+$/.test(value)) throw new ArchiveError(`Invalid tar ${field}`);\n\tconst size = Number(value);\n\tif (!Number.isSafeInteger(size) || size < 0) throw new ArchiveError(`Invalid tar ${field}`);\n\treturn size;\n}\n\nfunction isZeroBlock(buffer: Uint8Array, offset: number): boolean {\n\tfor (let index = 0; index < BLOCK_SIZE; index++) {\n\t\tif (buffer[offset + index] !== 0) return false;\n\t}\n\treturn true;\n}\n\nfunction checksumMatches(buffer: Uint8Array, offset: number): boolean {\n\tconst stored = readTarNumeric(buffer, offset + CHECKSUM_OFFSET, CHECKSUM_LENGTH);\n\tlet unsigned = 0;\n\tlet signed = 0;\n\tfor (let index = 0; index < BLOCK_SIZE; index++) {\n\t\tconst inChecksum = index >= CHECKSUM_OFFSET && index < CHECKSUM_OFFSET + CHECKSUM_LENGTH;","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/utils/src/ar/tar.ts#L130-L166","documentation":"parsePaxSize parses a size string taken from a PAX extended-header record ('size', 'GNU.sparse.realsize', etc.). This throw fires when the string is not pure decimal digits — the field name is interpolated into the message, e.g. \"Invalid tar member size\" or \"Invalid tar sparse real size\". PAX stores large values as decimal text, so any non-digit means the record is malformed.","triggerScenarios":"A PAX extended header (typeflag 'x'/'g') contains a size-ish record whose value has non-digit characters — e.g. `size=12abc\\n` or an empty/whitespace value — parsed during readTarEntriesFromBuffer.","commonSituations":"Archives written by non-conforming tools, hand-edited or corrupted PAX headers, or a writer that put a formatted (hex, suffixed) number into a PAX record.","solutions":["Inspect the PAX record in the archive (tar --to-stdout on the PaxHeaders member) and fix or regenerate the archive.","Ensure the tool that wrote the archive emits PAX numeric values as plain decimal ASCII digits.","Recreate the archive with a standard tar implementation (GNU tar, bsdtar) if a custom writer produced it.","Catch ArchiveError and reject the archive; the parser will not guess at malformed numerics."],"exampleFix":"// before (custom PAX writer)\nrecord = `size=0x${size.toString(16)}\\n`;\n// after\nrecord = `size=${size.toString(10)}\\n`;","handlingStrategy":"try-catch","validationCode":"// PAX numeric records must be pure decimal ASCII digits\nfunction isValidPaxNumber(value: string): boolean {\n  return /^\\d+$/.test(value);\n}","typeGuard":null,"tryCatchPattern":"try {\n  const entries = readTarEntriesFromBuffer(buffer, options);\n} catch (err) {\n  if (err instanceof ArchiveError && err.message.startsWith(\"Invalid tar \")) {\n    throw new Error(`Archive has a malformed PAX numeric record (${err.message})`);\n  }\n  throw err;\n}","preventionTips":["Write PAX numeric values as plain decimal strings only (no hex, suffixes, or whitespace).","Test custom tar writers against GNU tar/bsdtar round-trips.","Inspect PaxHeaders members with a reference tool when debugging malformed archives.","Reject archives that fail standard tar validation before indexing."],"tags":["tar","pax","archive","malformed-data"],"backgroundTag":"corrupt-tar-archive","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}