{"record":{"id":"0caf57652e5ad2e1","repo":"kubernetes/kops","slug":"unable-to-expand-the-template-s-error-s","errorCode":null,"errorMessage":"unable to expand the template: %s, error: %s","messagePattern":"unable to expand the template: (.+?), error: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/toolbox_template.go","lineNumber":147,"sourceCode":"\n\t// @check if we are just rendering the config value\n\tif options.configValue != \"\" {\n\t\tv, found := context[options.configValue]\n\t\tswitch found {\n\t\tcase true:\n\t\t\tfmt.Fprintf(out, \"%v\\n\", v)\n\t\tdefault:\n\t\t\tfmt.Fprintf(out, \"null\\n\")\n\t\t}\n\t\treturn nil\n\t}\n\n\t// @step: expand the list of templates into a list of files to render\n\tvar templates []string\n\tfor _, x := range options.templatePath {\n\t\tlist, err := expandFiles(utils.ExpandPath(x))\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"unable to expand the template: %s, error: %s\", x, err)\n\t\t}\n\t\ttemplates = append(templates, list...)\n\t}\n\n\tsnippets := make(map[string]string)\n\tfor _, x := range options.snippetsPath {\n\t\tlist, err := expandFiles(utils.ExpandPath(x))\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"unable to expand the snippets: %s, error: %s\", x, err)\n\t\t}\n\n\t\tfor _, j := range list {\n\t\t\tcontent, err := os.ReadFile(j)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"unable to read snippet: %s, error: %s\", j, err)\n\t\t\t}\n\t\t\tsnippets[path.Base(j)] = string(content)\n\t\t}","sourceCodeStart":129,"sourceCodeEnd":165,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/toolbox_template.go#L129-L165","documentation":"Returned by RunToolBoxTemplate of `kops toolbox template` when expandFiles() fails to expand one of the --template-path globs/paths into concrete files. The path is first passed through utils.ExpandPath (~ expansion), so the failure typically means the glob matched nothing or the path is unreadable/not a valid template file. The offending path and underlying error are embedded in the message.","triggerScenarios":"`kops toolbox template --template-path ./templates` (or a glob like ./templates/*.yaml) where the directory/file does not exist, the glob matches zero files, the path lacks read permission, or expandFiles encounters a filesystem error walking the path.","commonSituations":"Running the command from the wrong working directory so relative template paths don't resolve; typo in --template-path; glob pattern with no matches; templates directory not checked out / mounted in CI; missing read permissions.","solutions":["Verify the path exists: ls the --template-path value from the same working directory the command runs in","Use absolute paths or check the current directory; remember ~ is expanded but plain relative paths are cwd-dependent","If using a glob, confirm it actually matches files (test with `ls <glob>`)","Check file/directory read permissions for the user running kops","Ensure templates are present in CI containers/images before the toolbox command runs"],"exampleFix":"// before\nkops toolbox template --template-path ./templaes --snippets ./snippets --values values.yaml\n\n// after\nkops toolbox template --template-path ./templates --snippets ./snippets --values values.yaml","handlingStrategy":"validation","validationCode":"for _, p := range templatePaths {\n    expanded := utils.ExpandPath(p)\n    matches, err := filepath.Glob(expanded)\n    if err != nil || len(matches) == 0 {\n        return fmt.Errorf(\"template path %q matches no files\", p)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run the command from the directory where relative paths resolve, or use absolute paths","Test globs with `ls <glob>` before running kops toolbox template","Commit or mount template directories before CI steps that render them"],"tags":["kops","templates","filesystem","cli"],"backgroundTag":"template-path-not-found","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}