{"record":{"id":"f4f0180bdd9906bb","repo":"jenkinsci/jenkins","slug":"failed-to-unpack-s-d-bytes-read","errorCode":null,"errorMessage":"Failed to unpack %s (%d bytes read)","messagePattern":"Failed to unpack (.+?) \\((.+?) bytes read\\)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/hudson/FilePath.java","lineNumber":1114,"sourceCode":"    // this reads from arbitrary URL\n    private static final class Unpack extends MasterToSlaveFileCallable<Void> {\n        private final URL archive;\n\n        Unpack(URL archive) {\n            this.archive = archive;\n        }\n\n        @Override public Void invoke(File dir, VirtualChannel channel) throws IOException, InterruptedException {\n            try (InputStream in = archive.openStream()) {\n                CountingInputStream cis = new CountingInputStream(in);\n                try {\n                    if (archive.toExternalForm().endsWith(\".zip\")) {\n                        unzip(dir, cis);\n                    } else {\n                        readFromTar(\"input stream\", dir, TarCompression.GZIP.extract(cis));\n                    }\n                } catch (IOException x) {\n                    throw new IOException(String.format(\"Failed to unpack %s (%d bytes read)\", archive, cis.getByteCount()), x);\n                }\n            }\n            return null;\n        }\n    }\n\n    /**\n     * Reads the URL on the current VM, and streams the data to this file using the Remoting channel.\n     * <p>This is different from resolving URL remotely.\n     * If you instead wished to open an HTTP(S) URL on the remote side,\n     * prefer <a href=\"http://javadoc.jenkins.io/plugin/apache-httpcomponents-client-4-api/io/jenkins/plugins/httpclient/RobustHTTPClient.html#copyFromRemotely-hudson.FilePath-java.net.URL-hudson.model.TaskListener-\">{@code RobustHTTPClient.copyFromRemotely}</a>.\n     * @since 1.293\n     */\n    public void copyFrom(URL url) throws IOException, InterruptedException {\n        try (InputStream in = url.openStream()) {\n            copyFrom(in);\n        }\n    }","sourceCodeStart":1096,"sourceCodeEnd":1132,"githubUrl":"https://github.com/jenkinsci/jenkins/blob/2e228ff40b14dbc8b14ffbc6edf0e4383cf744fc/core/src/main/java/hudson/FilePath.java#L1096-L1132","documentation":"Thrown inside the Unpack MasterToSlaveFileCallable when unpacking a stream opened directly from a URL on the agent side fails. Unlike the controller-side variant it reports only bytes read (no Content-Length) because openStream() provides no length. Runs remotely via act(); failure bubbles up to install's retry/fallback.","triggerScenarios":"archive.openStream() yields a truncated or corrupt stream on the agent; agent cannot reach the URL (network/firewall); gzip/zip parse error mid-stream; agent disk full during write.","commonSituations":"Agent in a restricted network cannot fetch the URL directly (triggers fallback to controller download); archive served behind auth the agent lacks; agent tmp disk full.","solutions":["Check the agent can reach the URL (network/firewall) and has disk space.","Rely on the controller-side fallback if the agent fetch consistently fails (it will retry from controller).","Validate the archive integrity at the source.","Ensure agent java.io.tmpdir is writable and not full."],"exampleFix":"null","handlingStrategy":"retry","validationCode":"null","typeGuard":"null","tryCatchPattern":"try {\n    fp.act(new Unpack(archive));\n} catch (IOException e) {\n    if (e.getMessage().startsWith(\"Failed to unpack\")) {\n        // agent-side fetch failed — fall back to controller-side download\n    } else throw e;\n}","preventionTips":["Ensure agents can reach archive URLs, or rely on controller-side fallback.","Keep agent tmp/workspace disks from filling up.","Validate archive integrity at the source."],"tags":["unpack","agent","remoting","archive"],"backgroundTag":null,"analyzedSha":"2e228ff40b14dbc8b14ffbc6edf0e4383cf744fc","analyzedAt":"2026-08-14T07:07:15.274Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}