kubernetes/kops · error

unable to configuration file: %s, error: %s

Error message

unable to configuration file: %s, error: %s

What it means

newTemplateContext loads each configuration file given via --values (or config list) with os.ReadFile. If a file cannot be read (missing, permission denied), the command fails with this message naming the file and the OS error. Note the message has a known typo ('unable to configuration file').

Source

Thrown at cmd/kops/toolbox_template.go:244

		return fmt.Errorf("unable to write template: %s", err)
	}

	return nil
}

// newTemplateContext is responsible for loading the --values and build a context for the template
func newTemplateContext(files []string, values []string, stringValues []string) (map[string]interface{}, error) {
	context := make(map[string]interface{})

	for _, x := range files {
		list, err := expandFiles(utils.ExpandPath(x))
		if err != nil {
			return nil, err
		}
		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

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Verify the path exists and is readable: `ls -l <file>`.
  2. Correct the --values path or use an absolute path.
  3. If multiple --values flags are used, check each one; the error names the failing file.

Example fix

// before
kops toolbox template --values vals.yaml  # vals.yaml does not exist
// after
kops toolbox template --values ./config/vals.yaml  # correct, existing path
Defensive patterns

Strategy: validation

Validate before calling

info, err := os.Stat(valuesPath)
if err != nil { return fmt.Errorf("values file %s missing", valuesPath) }
if info.IsDir() { return fmt.Errorf("%s is a directory", valuesPath) }

Try / catch

out, err := exec.Command("kops", "toolbox", "template", "--values", p, ...).CombinedOutput()
if strings.Contains(string(out), "unable to configuration file") { verify path/permissions and retry }

Prevention

When it happens

Trigger: Running `kops toolbox template --values <file>` where the file does not exist, is unreadable, or is a directory.

Common situations: Typo in --values path; file deleted or moved; running in a container/CI where the values file was not copied; wrong relative path from the working directory.

Related errors


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