{"record":{"id":"4f816de737905551","repo":"helm/helm","slug":"invalid-json-in-values-schema-json-4f816d","errorCode":null,"errorMessage":"invalid JSON in values.schema.json","messagePattern":"invalid JSON in values\\.schema\\.json","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/chart/v2/util/save.go","lineNumber":211,"sourceCode":"\t\t\tif err := writeToTar(out, filepath.Join(base, \"Chart.lock\"), ldata, c.Lock.Generated); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\t// Save values.yaml\n\tfor _, f := range c.Raw {\n\t\tif f.Name == ValuesfileName {\n\t\t\tif err := writeToTar(out, filepath.Join(base, ValuesfileName), f.Data, f.ModTime); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\t// Save values.schema.json if it exists\n\tif c.Schema != nil {\n\t\tif !json.Valid(c.Schema) {\n\t\t\treturn errors.New(\"invalid JSON in \" + SchemafileName)\n\t\t}\n\t\tif err := writeToTar(out, filepath.Join(base, SchemafileName), c.Schema, c.SchemaModTime); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// Save templates\n\tfor _, f := range c.Templates {\n\t\tn := filepath.Join(base, f.Name)\n\t\tif err := writeToTar(out, n, f.Data, f.ModTime); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// Save files\n\tfor _, f := range c.Files {\n\t\tn := filepath.Join(base, f.Name)\n\t\tif err := writeToTar(out, n, f.Data, f.ModTime); err != nil {","sourceCodeStart":193,"sourceCodeEnd":229,"githubUrl":"https://github.com/helm/helm/blob/2a29f1770b62844b27197d2507377361d45ad7c0/pkg/chart/v2/util/save.go#L193-L229","documentation":"Thrown by the chart archive writer in pkg/chart/v2/util/save.go when a chart has a non-nil Schema ([]byte holding values.schema.json) whose bytes fail json.Valid. Helm keeps the schema as raw bytes on the Chart struct and only validates it at save time, right before writing values.schema.json into the tarball, so a syntactically broken JSON file is caught at packaging rather than at load.","triggerScenarios":"Calling (*chart.Chart).Save / SaveDir helpers (directly, or via 'helm package' / 'helm chart save') on a chart where c.Schema contains invalid JSON: trailing commas, // or /* */ comments, single-quoted strings, YAML pasted into the file, or a truncated file.","commonSituations":"Hand-editing values.schema.json with JSON5-style syntax, pasting YAML into it, a file cut off during copy or merge conflict resolution, or SDK code that assigns Chart.Schema from an unvalidated source before packaging. Usually surfaces in CI packaging steps.","solutions":["Validate and fix the file syntax: jq . values.schema.json reports the exact offset of the syntax error (look for trailing commas, comments, single quotes)","If the file was truncated or mangled by a merge, restore it from git: git checkout -- charts/myapp/values.schema.json","In Go code, gate Save with json.Valid(c.Schema) so the error message points at your code, not the tar writer"],"exampleFix":"// before\nchartObj.Schema = rawBytes // rawBytes may be invalid JSON\nerr := chartObj.Save(out, helmpath)\n\n// after\nif chartObj.Schema != nil && !json.Valid(chartObj.Schema) {\n\treturn fmt.Errorf(\"values.schema.json is not valid JSON: %w\", errSyntaxCheck)\n}\nerr := chartObj.Save(out, helmpath)","handlingStrategy":"validation","validationCode":"// before packaging, verify the schema bytes parse\nimport \"encoding/json\"\n\nif c.Schema != nil && !json.Valid(c.Schema) {\n\treturn fmt.Errorf(\"values.schema.json is not valid JSON; fix before packaging\")\n}\nreturn c.Save(out, path)","typeGuard":"func chartSchemaIsValidJSON(c *chartv2.Chart) bool {\n\treturn c.Schema == nil || json.Valid(c.Schema)\n}","tryCatchPattern":"if err := c.Save(w, path); err != nil {\n\tif strings.Contains(err.Error(), \"invalid JSON in values.schema.json\") {\n\t\t// schema syntax problem: validate with json.Valid, report byte offset, fix and retry\n\t}\n\treturn err\n}","preventionTips":["Run jq . values.schema.json as a pre-commit or CI check","Never paste YAML or comments into values.schema.json","Run helm lint (which validates the schema) before helm package in CI"],"tags":["json","chart","schema","packaging","archive"],"backgroundTag":null,"analyzedSha":"2a29f1770b62844b27197d2507377361d45ad7c0","analyzedAt":"2026-08-15T22:02:47.490Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}