{"record":{"id":"c8d089fe8376e3e7","repo":"theonedev/onedev","slug":"error-reading-chart-archive-e-getmessage","errorCode":null,"errorMessage":"Error reading chart archive: ${e.getMessage()}","messagePattern":"Error reading chart archive: (.+?)","errorType":"http","errorClass":"ClientException","httpStatus":400,"severity":"error","filePath":"server-plugin/server-plugin-pack-helm/src/main/java/io/onedev/server/plugin/pack/helm/HelmPackHandler.java","lineNumber":204,"sourceCode":"            Map<String, Object> metadata = null;\n            var bytes = baos.toByteArray();\n\n            try (var is = new TarInputStream(new GZIPInputStream(new ByteArrayInputStream(bytes)))) {\n                TarEntry entry;\n                while ((entry = is.getNextEntry()) != null) {\n                    String entryName = entry.getName();\n                    if (entryName.equals(\"Chart.yaml\") || entryName.endsWith(\"/Chart.yaml\")) {\n                        if (entry.getSize() > MAX_FILE_SIZE)\n                            throw new ClientException(SC_BAD_REQUEST, \"Chart.yaml is too large\");\n                        byte[] content = new byte[(int) entry.getSize()];\n                        is.read(content);\n                        var options = new LoaderOptions();\n                        metadata = new Yaml(new SafeConstructor(options)).load(new ByteArrayInputStream(content));\n                        break;\n                    }\n                }                \n            } catch (IOException e) {\n                throw new ClientException(SC_BAD_REQUEST, \"Error reading chart archive: \" + e.getMessage());\n            }\n\n            if (metadata == null) {\n                throw new ClientException(SC_BAD_REQUEST, \"Chart.yaml not found in the archive\");\n            }\n            \n            var chartName = (String) metadata.get(\"name\");\n            var chartVersion = (String) metadata.get(\"version\");\n            \n            if (chartName == null || chartVersion == null) {\n                throw new ClientException(SC_BAD_REQUEST, \"Chart name or version not specified\");\n            }            \n\n            var finalMetadata = metadata;\n\t\t\tvar lockName = \"update-pack:\" + projectId + \":\" + HelmPackSupport.TYPE + \":\" + chartName + \":\" + chartVersion;\n            LockUtils.run(lockName, () -> transactionService.run(() -> {\n                var project = projectService.load(projectId);\n","sourceCodeStart":186,"sourceCodeEnd":222,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-plugin/server-plugin-pack-helm/src/main/java/io/onedev/server/plugin/pack/helm/HelmPackHandler.java#L186-L222","documentation":"Thrown by HelmPackHandler.handle when an IOException occurs while reading entries of the uploaded .tgz chart archive (opening/reading the tar stream or extracting Chart.yaml). It is a 400 Bad Request telling the client the uploaded archive could not be read, with the underlying IOException message appended.","triggerScenarios":"POST/PUT of a Helm chart package to /~helm where the tar archive is corrupt, truncated, not gzip/tar formatted, or the upload stream fails mid-read so TarArchiveInputStream.getNextEntry/read throws IOException.","commonSituations":"Uploading a file that is not a real chart tgz (e.g. an HTML error page saved as .tgz), interrupted/partial uploads, proxies corrupting the body, or charts packaged with unusual compression.","solutions":["Re-package the chart with 'helm package <chart-dir>' and re-upload the resulting .tgz","Verify the file is a valid gzip tar: 'tar tzf chart.tgz' should list entries including Chart.yaml","Check network/proxy stability and re-upload; ensure the client sends the full request body","Check server logs for the wrapped IOException message to identify the exact read failure"],"exampleFix":"// before\ncurl -T corrupted-chart.tgz https://server/project/~helm\n// after\nhelm package mychart\ncurl -T mychart-1.0.0.tgz https://server/project/~helm","handlingStrategy":"validation","validationCode":"if (!file.getName().endsWith(\".tgz\")) throw new IllegalArgumentException(\"not a chart tgz\");\ntry (var in = new FileInputStream(file)) {\n    var tar = new TarArchiveInputStream(new GzipCompressorInputStream(in));\n    TarArchiveEntry e;\n    boolean hasChartYaml = false;\n    while ((e = tar.getNextTarEntry()) != null) if (e.getName().equals(\"Chart.yaml\")) { hasChartYaml = true; break; }\n    if (!hasChartYaml) throw new IllegalArgumentException(\"Chart.yaml missing at archive root\");\n}","typeGuard":null,"tryCatchPattern":"try { handler.upload(chartTgz); } catch (ClientException e) { log.error(\"chart archive rejected: {}\", e.getMessage()); }","preventionTips":["Always package with 'helm package', never hand-tar the chart","Verify the tgz with 'tar tzf' before upload","Use resumable/stable network paths for large uploads"],"tags":["helm","archive","io","upload"],"backgroundTag":"file-read-failed","analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}