zip.js signals archive faults (missing end-of-central-directory record,
unrecognized format, overlapping members, corrupt member data,
unsupported compression) as plain Errors. ZipArtifactReader passed them
through untyped, so the artifact provider's fallback reported every one
as `io` with no detail and told the caller to "check file access".
Type these faults at the ZIP reader boundary: structural and data
corruption become `format` failures and unsupported archive features
become `unavailable`, each carrying the zip.js reason as detail. This
covers enumeration, the getData rejection, and the WritableStream abort
path that delivers corrupt-data errors first.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Problem
rea inspect-artifact(andinventory_artifact/extract_artifact) on a truncated or corrupt ZIP/APK/JAR returned:{"code":"artifact_operation_failed","message":"Artifact could not be read or written. Check file access and try again.","details":{"operation":"inspect_artifact","reason":"io"}}The file is readable; the archive is malformed. The
ioreason gives the wrong advice and drops the reason.Root cause
zip.js throws plain
Errors for archive faults (End of central directory not found,File format is not recognized,Overlapping entry found,Invalid compressed data,Compression method not supported, …).ZipArtifactReaderpassed them through untyped, sotranslateArtifactFailure's fallback turned each one intoArtifactOperationError(…, "io")with no detail.Fix
The fix is at the producing boundary,
ZipArtifactReader. zip.js faults are matched against its exportedERR_*constants and converted into typedArtifactReaderFailures:formatfor structural and data corruption (EOCD/central directory/local header missing, bad format, overlapping or out-of-bounds entries, invalid CRC/compressed data/size, ambiguous archive)unavailablefor unsupported archive features (compression method, encryption method, encrypted central directory, split archives)The typing covers all three paths an error can take: entry enumeration, the
getDatarejection, and theWritableStreamabort. Corrupt-data errors reach the abort path first. Unrecognized errors (real filesystem I/O) are passed through unchanged.After the fix:
{"message":"Artifact is invalid or has changed. Get a fresh copy and try again.","details":{"operation":"inspect_artifact","reason":"format","detail":"ZIP archive is malformed: End of central directory not found"}}Other ZIP consumers (Flutter APK reader, JADX JAR probe, SAZ decoder) keep their own mapping. Flutter and JADX messages now embed the clearer
ZIP archive is malformed: …text.Validation
tests/boundary/filesystem/artifactZipIntegrity.test.ts: the overlapping, corrupt-member and truncated ZIP cases now assertreason: "format"plus the zip.js detail. These tests previously pinnedio. A new case covers an unsupported compression method →unavailable.npm run test:focusedon all 52 test files that exercise ZIP/APK/SAZ/JADX/Flutter readers: 557 passed, 3 skipped.npm run check:fastpasses.inspect-artifacton truncatedPK\3\4, a bare EOCD signature and a cut-off ZIP before and after the change.identify-flutter-buildstill reportsinvalid_format.Remaining
identify_flutter_buildand SAZ decoding still classify every non-limit ZIP failure as malformed input, genuine I/O errors included. They could now useArtifactReaderFailure.reason, but that changes their error contracts, so it is left for a separate change.🤖 Generated with Claude Code