{"record":{"id":"996b28ccf7d98dbb","repo":"helm/helm","slug":"stream-does-not-appear-to-be-a-valid-chart-file-d","errorCode":null,"errorMessage":"stream does not appear to be a valid chart file (details: %w)","messagePattern":"stream does not appear to be a valid chart file \\(details: %w\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/chart/loader/load.go","lineNumber":166,"sourceCode":"\t\t\tcase c3.APIVersionV3:\n\t\t\t\treturn c3load.Load(name)\n\t\t\tdefault:\n\t\t\t\treturn nil, errors.New(\"unsupported chart version\")\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil, errors.New(\"unable to detect chart version, no Chart.yaml found\")\n}\n\n// LoadArchive loads from a reader containing a compressed tar archive.\nfunc LoadArchive(in io.Reader) (chart.Charter, error) {\n\t// Note: This function is for use by SDK users such as Flux.\n\n\tfiles, err := archive.LoadArchiveFiles(in)\n\tif err != nil {\n\t\tif errors.Is(err, gzip.ErrHeader) {\n\t\t\treturn nil, fmt.Errorf(\"stream does not appear to be a valid chart file (details: %w)\", err)\n\t\t}\n\t\treturn nil, fmt.Errorf(\"unable to load chart archive: %w\", err)\n\t}\n\n\tfor _, f := range files {\n\t\tif f.Name == \"Chart.yaml\" {\n\t\t\tc := new(chartBase)\n\t\t\tif err := yaml.Unmarshal(f.Data, c); err != nil {\n\t\t\t\treturn c, fmt.Errorf(\"cannot load Chart.yaml: %w\", err)\n\t\t\t}\n\t\t\tswitch c.APIVersion {\n\t\t\tcase c2.APIVersionV1, c2.APIVersionV2, \"\":\n\t\t\t\treturn c2load.LoadFiles(files)\n\t\t\tcase c3.APIVersionV3:\n\t\t\t\treturn c3load.LoadFiles(files)\n\t\t\tdefault:\n\t\t\t\treturn nil, errors.New(\"unsupported chart version\")\n\t\t\t}","sourceCodeStart":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/helm/helm/blob/2a29f1770b62844b27197d2507377361d45ad7c0/pkg/chart/loader/load.go#L148-L184","documentation":"Stream variant of the bad-archive error, thrown by loader.LoadArchive(io.Reader) — the SDK entry point used by tools such as Flux. archive.LoadArchiveFiles returned an error matching gzip.ErrHeader, meaning the byte stream does not start with a valid gzip header, so it cannot be a chart tarball.","triggerScenarios":"Passing LoadArchive a reader over an uncompressed tar, a base64 body that was never decoded, an OCI manifest JSON, an HTTP error page, or a stream whose first bytes were already consumed by earlier code (e.g. peeking with bufio.Reader and discarding).","commonSituations":"GitOps controllers (Flux) reconciling a chart URL that returns HTML/JSON; SDK users double-reading a request body; proxies injecting an error page; wrong artifact pulled from a registry.","solutions":["Consume the first bytes and confirm gzip magic 0x1f 0x8b before calling LoadArchive; log them on failure.","Fix the upstream source: correct URL/OCI reference so the body is a real gzip tgz.","If the body may be base64-encoded, decode it before passing the reader.","Make sure nothing reads the stream before LoadArchive; if you need peeking, use bufio.Reader and pass the same bufio.Reader (it replays the peeked bytes)."],"exampleFix":"// before\nch, err := loader.LoadArchive(resp.Body) // resp.Body was an HTML error page\n\n// after\nbr := bufio.NewReader(resp.Body)\nif magic, _ := br.Peek(2); len(magic) < 2 || magic[0] != 0x1f || magic[1] != 0x8b {\n    body, _ := io.ReadAll(io.LimitReader(br, 256))\n    return fmt.Errorf(\"not a gzip chart stream, got %q\", body)\n}\nch, err := loader.LoadArchive(br)","handlingStrategy":"validation","validationCode":"// Peek gzip magic on the stream before LoadArchive\nbr := bufio.NewReader(src)\nhead, _ := br.Peek(2)\nif len(head) == 2 && head[0] == 0x1f && head[1] == 0x8b {\n\tch, err := loader.LoadArchive(br) // same reader: peeked bytes are replayed\n} else {\n\terr = fmt.Errorf(\"source did not return a gzip chart stream\")\n}","typeGuard":null,"tryCatchPattern":"if _, err := loader.LoadArchive(r); err != nil {\n\tif strings.Contains(err.Error(), \"does not appear to be a valid chart file\") {\n\t\t// body is not a chart: log response snippet, fix the source URL/reference\n\t}\n}","preventionTips":["Peek before parsing when the remote source is untrusted.","Check HTTP status explicitly; do not parse error bodies as charts.","In Flux-style controllers, validate the artifact digest before reconciliation."],"tags":["helm","chart","gzip","stream","sdk","flux"],"backgroundTag":null,"analyzedSha":"2a29f1770b62844b27197d2507377361d45ad7c0","analyzedAt":"2026-08-15T22:02:47.490Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}