kubernetes/kops · error

failed parsing --set-string data: %s

Error message

failed parsing --set-string data: %s

What it means

Values passed via --set-string are parsed with strvals.ParseIntoString, which keeps all values as strings. Malformed syntax fails with this error wrapping the strvals error. Same grammar as --set but the value is forced to a string.

Source

Thrown at cmd/kops/toolbox_template.go:265

			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 {
		return nil, err
	}
	// @check if not a directory and return as is
	if !stat.IsDir() {
		return []string{path}, nil
	}
	// @step: iterate the directory and get all the files

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Ensure each --set-string argument is key=value form: `--set-string key=value`.
  2. Use dot/bracket notation correctly for nested keys: `--set-string a.b=1`.
  3. Use --set instead of --set-string when typed (int/bool) values are desired.

Example fix

// before
kops toolbox template --set-string version
// after
kops toolbox template --set-string version=1.2.3
Defensive patterns

Strategy: validation

Validate before calling

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

Try / catch

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

Prevention

When it happens

Trigger: Running `kops toolbox template --set-string foo` (missing '='), or invalid key syntax such as unbalanced brackets in `a[0]=x` forms.

Common situations: Missing '=' separator; typos in nested key paths; shell quoting stripping characters needed by the parser.

Related errors


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