MuntashirAkon/AppManager · error · IOException
Failed to read Paxheader. Encountered a non-number while…
Error message
Failed to read Paxheader. Encountered a non-number while reading length
What it means
Thrown by TarUtils.parsePaxHeaders while parsing the decimal length prefix of a PAX record when a byte that is not an ASCII digit is found (COMPRESS-530 fix). The PAX format requires records to start with a decimal byte count; anything else is malformed input, previously causing silent bad parses.
Solutions
- Verify the archive is valid and not corrupted (checksum, tar -tvf test)
- Ensure the stream is positioned at the actual PAX header record, not elsewhere
- Re-transfer in binary mode if the file passed through text-mode transfer (line-ending mangling)
- Catch IOException and reject the archive
Defensive patterns
Strategy: validation
Validate before calling
// sanity-check the file starts like a tar before parsing
byte[] h = new byte[512];
if (!Magic.isTarHeader(h)) throw new IOException("Not a valid tar archive"); Try / catch
try {
// read tar
} catch (IOException e) {
if (e.getMessage().contains("non-number while reading length")) {
throw new CorruptArchiveException("PAX record length prefix is not numeric", e);
}
throw e;
} Prevention
- Transfer archives in binary mode only (no ASCII/FTP text mode)
- Validate the archive externally (tar -tvf) before parsing
- Don't seek/reposition the stream to arbitrary offsets before parsePaxHeaders
When it happens
Trigger: Reading a stream positioned at data that is not a valid PAX record length: corrupt archive, wrong stream offset, or a non-PAX header misinterpreted as PAX data.
Common situations: Mixing archive formats (reading a ustar/oldgnu header as pax), corruption from FTP ASCII-mode transfers, or fuzzed files.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- Failed to read Paxheader.GNU.sparse.offset is expected…
- Failed to read Paxheader.Value should end with a newline
- Error detected parsing the pax header
- Failed to read Paxheader. Expected
- Paxheader value size
AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12).
Data as JSON: /api/errors/a1bd9b199fc8f4d7.
Report an issue: GitHub.
Appendix: source
Thrown at app/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java:760
if (keyword.equals("GNU.sparse.numbytes")) {
if (offset == null) {
throw new IOException("Failed to read Paxheader." +
"GNU.sparse.offset is expected before GNU.sparse.numbytes shows up.");
}
sparseHeaders.add(new TarArchiveStructSparse(offset, Long.parseLong(value)));
offset = null;
}
}
break;
}
coll.write((byte) ch);
}
break; // Processed single header
}
// COMPRESS-530 : throw if we encounter a non-number while reading length
if (ch < '0' || ch > '9') {
throw new IOException("Failed to read Paxheader. Encountered a non-number while reading length");
}
len *= 10;
len += ch - '0';
}
if (ch == -1){ // EOF
break;
}
}
if (offset != null) {
// offset but no numBytes
sparseHeaders.add(new TarArchiveStructSparse(offset, 0));
}
return headers;
}
/**
* For PAX Format 0.1, the sparse headers are stored in a single variable : GNU.sparse.mapView on GitHub (pinned to 0152f468fc)