{"record":{"id":"bb460a218a6d3991","repo":"grafana/k6","slug":"invalid-template-type-q","errorCode":null,"errorMessage":"invalid template type %q","messagePattern":"invalid template type %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cmd/templates/templates.go","lineNumber":104,"sourceCode":"\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\nfunc ExecuteTemplate(w io.Writer, tmpl *template.Template, args TemplateArgs) error {\n\treturn tmpl.Execute(w, args)\n}","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/cmd/templates/templates.go#L86-L122","documentation":"GetTemplate's fallback error: the argument matched neither a built-in template type nor a readable template file, and no file with that name exists in the current directory (the variant with 'did you mean ./%s?' fires when such a local file exists). Pure input validation on the template name passed to 'k6 new'.","triggerScenarios":"Thrown at internal/cmd/templates/templates.go:104 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use a built-in template type supported by 'k6 new' (e.g. default, browser-module, grpc-module)","Or pass a path to an existing custom template file","If the file is in the current directory, prefix it with ./ (e.g. k6 new --template ./my.js)"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}