{"record":{"id":"e2e35d5a18c72b21","repo":"jenkinsci/jenkins","slug":"failed-to-unpack-s-d-bytes-read-of-total-d","errorCode":null,"errorMessage":"Failed to unpack %s (%d bytes read of total %d)","messagePattern":"Failed to unpack (.+?) \\((.+?) bytes read of total (.+?)\\)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/hudson/FilePath.java","lineNumber":1063,"sourceCode":"                        timestamp.write(resultEtag, \"UTF-8\");\n                    }\n                    timestamp.touch(sourceTimestamp);\n                    return true;\n                } catch (IOException x) {\n                    Functions.printStackTrace(x, listener.error(\"Failed to download \" + archive + \" from agent; will retry from controller\"));\n                }\n            }\n\n            // for HTTP downloads, enable automatic retry for added resilience\n            InputStream in = archive.getProtocol().startsWith(\"http\") ? ProxyConfiguration.getInputStream(archive) : con.getInputStream();\n            CountingInputStream cis = new CountingInputStream(in);\n            try {\n                if (archive.toExternalForm().endsWith(\".zip\"))\n                    unzipFrom(cis);\n                else\n                    untarFrom(cis, TarCompression.GZIP);\n            } catch (IOException e) {\n                throw new IOException(String.format(\"Failed to unpack %s (%d bytes read of total %d)\",\n                        archive, cis.getByteCount(), con.getContentLength()), e);\n            }\n            if (resultEtag != null && !equalETags(etag, resultEtag)) {\n                /* Store the ETag value in the timestamp file for later use */\n                timestamp.write(resultEtag, \"UTF-8\");\n            }\n            timestamp.touch(sourceTimestamp);\n            return true;\n        } catch (IOException e) {\n            throw new IOException(\"Failed to install \" + archive + \" to \" + remote, e);\n        }\n    }\n\n    /* Return true if etag1 equals etag2 as defined by the etag specification\n       https://httpwg.org/specs/rfc9110.html#field.etag\n     */\n    private boolean equalETags(String etag1, String etag2) {\n        if (etag1 == null || etag2 == null) {","sourceCodeStart":1045,"sourceCodeEnd":1081,"githubUrl":"https://github.com/jenkinsci/jenkins/blob/2e228ff40b14dbc8b14ffbc6edf0e4383cf744fc/core/src/main/java/hudson/FilePath.java#L1045-L1081","documentation":"Thrown during FilePath.install(...) when unpacking a downloaded zip/tar on the controller fails. The message reports bytes read vs the server's Content-Length so truncation is obvious. The IOException from unzipFrom/untarFrom is chained. This is the inner unpack failure; it is then re-wrapped by the outer 'Failed to install' handler.","triggerScenarios":"HTTP download truncated (bytes read < content length); corrupt or incomplete archive stream; gzip stream ended early; server reported a wrong Content-Length; connection dropped mid-transfer.","commonSituations":"Installing a tool/plugin/tool from a slow or proxy-mangled URL; server behind a CDN serving partial content; disk filled during unpack; mismatched archive type vs extension (.zip that is actually tar).","solutions":["Compare bytes read vs total: if truncated, retry the download or fix the source URL.","Verify the archive is valid: download separately and test with unzip/tar.","Ensure the URL extension matches the format (.zip -> zip, else treated as gzipped tar).","Check disk space and network stability; use a mirror if the source is unreliable."],"exampleFix":"null","handlingStrategy":"retry","validationCode":"URLConnection con = archive.openConnection();\nint expected = con.getContentLength();\n// after download, compare actual bytes to expected before unpacking","typeGuard":"null","tryCatchPattern":"try {\n    fp.install(archive, listener);\n} catch (IOException e) {\n    if (e.getMessage().startsWith(\"Failed to unpack\")) {\n        // truncated/corrupt download — retry from a stable source\n    } else throw e;\n}","preventionTips":["Download from reliable mirrors/CDNs with retry logic.","Verify byte count vs Content-Length before unpacking.","Match the URL extension to the archive format (.zip vs tar.gz)."],"tags":["unpack","download","network","archive"],"backgroundTag":null,"analyzedSha":"2e228ff40b14dbc8b14ffbc6edf0e4383cf744fc","analyzedAt":"2026-08-14T07:07:15.274Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}