kubernetes/kops · error

failed parsing --set data: %s

Error message

failed parsing --set data: %s

What it means

Raised in newTemplateContext when a value passed via --set cannot be parsed by helmstrvals.ParseInto. The offending string is not valid Helm-style set syntax (e.g. unbalanced braces or bad dot/key syntax), so the template context cannot be built.

Source

Thrown at cmd/kops/toolbox_template.go:258

		}
		for _, j := range list {
			content, err := os.ReadFile(j)
			if err != nil {
				return nil, fmt.Errorf("unable to configuration file: %s, error: %s", j, err)
			}

			ctx := make(map[string]interface{})
			if err := utils.YamlUnmarshal(content, &ctx); err != nil {
				return nil, fmt.Errorf("unable decode the configuration file: %s, error: %v", j, err)
			}
			context = mergeMaps(context, ctx)
		}
	}

	// User specified a value via --set
	for _, value := range values {
		if err := helmstrvals.ParseInto(value, context); err != nil {
			return nil, fmt.Errorf("failed parsing --set data: %s", err)
		}
	}

	// User specified a value via --set-string
	for _, value := range stringValues {
		if err := helmstrvals.ParseIntoString(value, context); err != nil {
			return nil, fmt.Errorf("failed parsing --set-string data: %s", err)
		}
	}

	return context, nil
}

// expandFiles is responsible for resolving any references to directories
func expandFiles(path string) ([]string, error) {
	// @check if the path is a directory, if not we can return straight away
	stat, err := os.Stat(path)
	if err != nil {

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Ensure each --set argument is key=value form: `--set key=value`.
  2. Quote values with special characters: `--set key='a,b'`.
  3. Use nested dot notation correctly: `--set a.b=c`, and lists via `--set a[0]=x`.

Example fix

// before
kops toolbox template --set replicas
// after
kops toolbox template --set replicas=3
Defensive patterns

Strategy: validation

Validate before calling

for _, v := range setArgs {
  if !strings.Contains(v, "=") { return fmt.Errorf("invalid --set %q: expected key=value", v) }
}

Try / catch

out, err := exec.Command("kops", "toolbox", "template", "--set", v, ...).CombinedOutput()
if strings.Contains(string(out), "failed parsing --set data") { fix key=value syntax and retry }

Prevention

When it happens

Trigger: Running `kops toolbox template --set foo` (no '='), `--set a=b=c` in an invalid form, or unbalanced braces/brackets in nested syntax like `a.b=c` or `a={1,2}`.

Common situations: Forgetting '=' between key and value; unquoted values containing commas or braces; spaces inside --set expressions; shell eating quotes.

Related errors


AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05). Data as JSON: /api/errors/95b4ed19abb8b072. Report an issue: GitHub.