{"record":{"id":"319225f838f63e30","repo":"grafana/k6","slug":"invalid-template-type-q-did-you-mean-s","errorCode":null,"errorMessage":"invalid template type %q, did you mean ./%s?","messagePattern":"invalid template type %q, did you mean \\./(.+?)\\?","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cmd/templates/templates.go","lineNumber":101,"sourceCode":"\n\t\t// Read the template content using the provided filesystem\n\t\tcontent, err := fsext.ReadFile(tm.fs, tplPath)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to read template file %s: %w\", tpl, err)\n\t\t}\n\n\t\ttmpl, err := template.New(filepath.Base(tplPath)).Parse(string(content))\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to parse template file %s: %w\", tpl, err)\n\t\t}\n\n\t\treturn tmpl, nil\n\t}\n\n\t// Check if there's a file with this name in current directory\n\texists, err := fsext.Exists(tm.fs, fsext.JoinFilePath(\".\", tpl))\n\tif err == nil && exists {\n\t\treturn nil, fmt.Errorf(\"invalid template type %q, did you mean ./%s?\", tpl, tpl)\n\t}\n\n\treturn nil, fmt.Errorf(\"invalid template type %q\", tpl)\n}\n\n// isFilePath checks if the given string looks like a file path by detecting path separators\n// We assume that built-in template names don't contain path separators\nfunc isFilePath(path string) bool {\n\treturn strings.ContainsRune(path, filepath.Separator) || strings.ContainsRune(path, '/')\n}\n\n// TemplateArgs represents arguments passed to templates\ntype TemplateArgs struct {\n\tScriptName string\n\tProjectID  string\n}\n\n// ExecuteTemplate applies the template with provided arguments and writes to the provided writer","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/cmd/templates/templates.go#L83-L119","documentation":"The --template value is not a built-in name and contains no path separator (so it is not treated as a file), but a file with exactly that name exists in the current directory. k6 guesses the user forgot the ./ prefix and reports \"invalid template type \\\"<name>\\\", did you mean ./<name>?\" instead of silently picking the local file.","triggerScenarios":"Running 'k6 new --template=mytpl.js script.js' while ./mytpl.js exists in the cwd; isFilePath() returns false because the value has no '/' or separator, so it is classified as a template type name and falls through to the local-file hint.","commonSituations":"Users expecting shell-like path resolution from k6 arguments; copy-pasted commands that omit ./; switching between built-in names and local files.","solutions":["Prefix the file with ./: k6 new --template=./mytpl.js script.js","Or pass an absolute path to the template file","For built-ins, use the exact reserved names (minimal, protocol, browser)"],"exampleFix":"# before\nk6 new --template=mytpl.js script.js\n# after\nk6 new --template=./mytpl.js script.js","handlingStrategy":"validation","validationCode":"# Normalize local template files to ./ form before invoking k6\ntpl=mytpl.js\n[ -f \"$tpl\" ] && tpl=\"./$tpl\"\nk6 new --template=\"$tpl\" script.js","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always type ./ before local template file names","Remember: bare names are template types; paths need a separator","Read the 'did you mean ./x?' hint literally — it names the fix"],"tags":["cli","templates","usability"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}