{"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/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/cmd/templates/templates.go#L86-L122","documentation":"The --template value matched no built-in template type, contains no path separator, and no file with that name exists in the current directory, so k6 reports \"invalid template type \\\"<tpl>\\\"\". Built-in types are selected by name (MinimalTemplate, ProtocolTemplate, BrowserTemplate); anything else must be a file path containing a separator.","triggerScenarios":"Typos such as --template=minimal-new or --template=browsr; passing a bare filename that does not exist in the cwd; using a template name that exists only in a different k6 version.","commonSituations":"Version differences where a template name exists in newer k6 but not the installed one; outdated blog posts or docs listing template names; copy-paste errors.","solutions":["Use one of the built-in names supported by your build: minimal, protocol, browser (check 'k6 new --help')","Pass an existing template file via ./relative or an absolute path","Upgrade k6 if documentation references a template your version lacks"],"exampleFix":"# before\nk6 new --template=browsr script.js\n# after\nk6 new --template=browser script.js","handlingStrategy":"validation","validationCode":"# Allow-list built-in names; anything else must be an existing file\ncase \"$tpl\" in\n  minimal|protocol|browser) ;;\n  *) [ -f \"$tpl\" ] || { echo \"unknown template: $tpl\" >&2; exit 2; } ;;\nesac\nk6 new --template=\"$tpl\" script.js","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check 'k6 new --help' for the template names your build supports","Double-check spelling of built-in template names","Upgrade k6 when docs reference templates your binary lacks"],"tags":["cli","templates","validation"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}