helm/helm · error

invalid JSON in values.schema.json

Error message

invalid JSON in values.schema.json

What it means

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.

Source

Thrown at pkg/chart/v2/util/save.go:211

			if err := writeToTar(out, filepath.Join(base, "Chart.lock"), ldata, c.Lock.Generated); err != nil {
				return err
			}
		}
	}

	// Save values.yaml
	for _, f := range c.Raw {
		if f.Name == ValuesfileName {
			if err := writeToTar(out, filepath.Join(base, ValuesfileName), f.Data, f.ModTime); err != nil {
				return err
			}
		}
	}

	// Save values.schema.json if it exists
	if c.Schema != nil {
		if !json.Valid(c.Schema) {
			return errors.New("invalid JSON in " + SchemafileName)
		}
		if err := writeToTar(out, filepath.Join(base, SchemafileName), c.Schema, c.SchemaModTime); err != nil {
			return err
		}
	}

	// Save templates
	for _, f := range c.Templates {
		n := filepath.Join(base, f.Name)
		if err := writeToTar(out, n, f.Data, f.ModTime); err != nil {
			return err
		}
	}

	// Save files
	for _, f := range c.Files {
		n := filepath.Join(base, f.Name)
		if err := writeToTar(out, n, f.Data, f.ModTime); err != nil {

View on GitHub (pinned to 2a29f1770b)

Solutions

  1. 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)
  2. If the file was truncated or mangled by a merge, restore it from git: git checkout -- charts/myapp/values.schema.json
  3. In Go code, gate Save with json.Valid(c.Schema) so the error message points at your code, not the tar writer

Example fix

// before
chartObj.Schema = rawBytes // rawBytes may be invalid JSON
err := chartObj.Save(out, helmpath)

// after
if chartObj.Schema != nil && !json.Valid(chartObj.Schema) {
	return fmt.Errorf("values.schema.json is not valid JSON: %w", errSyntaxCheck)
}
err := chartObj.Save(out, helmpath)
Defensive patterns

Strategy: validation

Validate before calling

// before packaging, verify the schema bytes parse
import "encoding/json"

if c.Schema != nil && !json.Valid(c.Schema) {
	return fmt.Errorf("values.schema.json is not valid JSON; fix before packaging")
}
return c.Save(out, path)

Type guard

func chartSchemaIsValidJSON(c *chartv2.Chart) bool {
	return c.Schema == nil || json.Valid(c.Schema)
}

Try / catch

if err := c.Save(w, path); err != nil {
	if strings.Contains(err.Error(), "invalid JSON in values.schema.json") {
		// schema syntax problem: validate with json.Valid, report byte offset, fix and retry
	}
	return err
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Related errors


AI-assisted analysis of helm/helm@2a29f1770b (2026-08-15). Data as JSON: /api/errors/4f816de737905551. Report an issue: GitHub.