{"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/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/cmd/templates/templates.go#L83-L119","documentation":"`k6 new -t NAME` first matches built-in names (minimal, protocol, browser). A value without path separators that is not built-in falls through: if a file with that name exists in the current directory, k6 assumes you meant to use it as a file template but forgot the ./ prefix, and emits this 'did you mean' hint. The sibling message without the hint fires when no such file exists.","triggerScenarios":"k6 new -t script.js when ./script.js exists → this error suggesting ./script.js; k6 new -t minimal.js (a local file) instead of -t minimal or -t ./minimal.js.","commonSituations":"Trying to base a new script on an existing local file and omitting ./; habit from other CLIs where bare filenames resolve as files.","solutions":["Prefix the path so it is treated as a file: k6 new -t ./script.js new-script.js","Or use a built-in template name: minimal, protocol, or browser"],"exampleFix":"# before\nk6 new -t script.js new-script.js\n\n# after\nk6 new -t ./script.js new-script.js","handlingStrategy":"validation","validationCode":"# decide template intent before invoking k6 new\nBUILTINS=\"minimal protocol browser\"\ntpl=\"$1\"\ncase \" $BUILTINS \" in\n  *\" $tpl \"*) ;;                                              # built-in: use as-is\n  *) case \"$tpl\" in */*|*\\\\*) ;;                              # has a separator: file path\n       *) if [ -e \"./$tpl\" ]; then tpl=\"./$tpl\"; else echo \"invalid template type '$tpl'\" >&2; exit 1; fi;;\n     esac;;\nesac\nk6 new -t \"$tpl\" new-script.js","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always prefix local template files with ./ — bare names are matched against built-ins first","Memorize the built-in set: minimal, protocol, browser","When the error appears, check whether a file with that name sits in the current directory; the fix is one './' away"],"tags":["k6","k6-new","template","cli-usage","path"],"backgroundTag":"invalid-cli-flag-value","analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}