theonedev/onedev · error · ClientException

Chart.yaml is too large

Error message

Chart.yaml is too large

What it means

After unpacking the uploaded chart tarball in memory, HelmPackHandler scans entries for Chart.yaml (at root or any directory depth). If the matching entry's declared size exceeds MAX_FILE_SIZE, it throws ClientException with HTTP 400 rather than loading it into the YAML parser — a defensive limit against pathological Chart.yaml files.

Source

Thrown at server-plugin/server-plugin-pack-helm/src/main/java/io/onedev/server/plugin/pack/helm/HelmPackHandler.java:195

            } else {
                try (var is = request.getInputStream()) {
                    var copied = IOUtils.copyWithMaxSize(is, baos, MAX_FILE_SIZE);
                    if (copied == -1)
                        throw new ClientException(SC_NOT_ACCEPTABLE, "Chart archive exceeds maximum size: " + MAX_FILE_SIZE);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }    
            }
            Map<String, Object> metadata = null;
            var bytes = baos.toByteArray();

            try (var is = new TarInputStream(new GZIPInputStream(new ByteArrayInputStream(bytes)))) {
                TarEntry entry;
                while ((entry = is.getNextEntry()) != null) {
                    String entryName = entry.getName();
                    if (entryName.equals("Chart.yaml") || entryName.endsWith("/Chart.yaml")) {
                        if (entry.getSize() > MAX_FILE_SIZE)
                            throw new ClientException(SC_BAD_REQUEST, "Chart.yaml is too large");
                        byte[] content = new byte[(int) entry.getSize()];
                        is.read(content);
                        var options = new LoaderOptions();
                        metadata = new Yaml(new SafeConstructor(options)).load(new ByteArrayInputStream(content));
                        break;
                    }
                }                
            } catch (IOException e) {
                throw new ClientException(SC_BAD_REQUEST, "Error reading chart archive: " + e.getMessage());
            }

            if (metadata == null) {
                throw new ClientException(SC_BAD_REQUEST, "Chart.yaml not found in the archive");
            }
            
            var chartName = (String) metadata.get("name");
            var chartVersion = (String) metadata.get("version");
            

View on GitHub (pinned to d44925c47c)

Solutions

  1. Inspect and clean Chart.yaml so it is a small, normal chart metadata file (name, version, apiVersion, dependencies).
  2. Move large data into values.yaml or separate files instead of Chart.yaml.
  3. Repackage: helm package . after fixing, then re-push.
  4. If legitimately large metadata is required, increase MAX_FILE_SIZE in HelmPackHandler and redeploy the plugin.

Example fix

// before (Chart.yaml bloated with embedded data)
apiVersion: v2
name: mychart
version: 0.1.0
# ...3 MB of dumped config...
// after
apiVersion: v2
name: mychart
version: 0.1.0
description: chart metadata kept small
Defensive patterns

Strategy: validation

Validate before calling

# ensure Chart.yaml is small and well-formed before packaging
[ $(stat -c%s Chart.yaml) -le 10485760 ] || { echo 'Chart.yaml too large'; exit 1; }
helm lint . && helm package .

Try / catch

try {
    helmPush(chartTgz);
} catch (ClientException e) {
    if (String(e).contains('Chart.yaml is too large')) throw new IllegalStateException("Chart.yaml must be a small metadata file", e);
    throw e;
}

Prevention

When it happens

Trigger: Publishing a chart whose Chart.yaml (entry.getSize()) is larger than MAX_FILE_SIZE — e.g. generated Chart.yaml with thousands of appended values, embedded data blobs, or a crafted/oversized file.

Common situations: Templating mistakes that dump large data into Chart.yaml; mis-built charts where Chart.yaml was overwritten by a values file; malicious uploads attempting resource exhaustion via huge YAML files.

Understand the failure class

Background: "File too large" / "file size exceeds limit" errors: why libraries cap file sizes and how to fix them — this error's family across 46 libraries.

Related errors


AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06). Data as JSON: /api/errors/65addba77bc99a14. Report an issue: GitHub.