{"record":{"id":"0af339886aebcbad","repo":"grafana/k6","slug":"error-retrieving-template-w","errorCode":null,"errorMessage":"error retrieving template: %w","messagePattern":"error retrieving template: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cmd/new.go","lineNumber":55,"sourceCode":"\t}\n\n\tfileExists, err := fsext.Exists(c.gs.FS, target)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif fileExists && !c.overwriteFiles {\n\t\treturn fmt.Errorf(\"%s already exists. Use the `--force` flag to overwrite it\", target)\n\t}\n\n\t// Initialize template manager and validate template before creating any files\n\ttm, err := templates.NewTemplateManager(c.gs.FS)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error initializing template manager: %w\", err)\n\t}\n\n\ttmpl, err := tm.GetTemplate(c.templateType)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error retrieving template: %w\", err)\n\t}\n\n\t// Prepare template arguments\n\targsStruct := templates.TemplateArgs{\n\t\tScriptName: target,\n\t\tProjectID:  c.projectID,\n\t}\n\n\t// First render the template to a buffer to validate it\n\tvar buf strings.Builder\n\tif err := templates.ExecuteTemplate(&buf, tmpl, argsStruct); err != nil {\n\t\treturn fmt.Errorf(\"failed to execute template %s: %w\", c.templateType, err)\n\t}\n\n\t// Only create the file after template rendering succeeds\n\tfd, err := c.gs.FS.Create(target)\n\tif err != nil {\n\t\treturn err","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/cmd/new.go#L37-L73","documentation":"Wrapped error in 'k6 new': the requested --template value does not match a built-in template (minimal, protocol, browser) and cannot be resolved as a custom template file path, so tm.GetTemplate failed.","triggerScenarios":"Thrown at internal/cmd/new.go:55 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use one of the built-in template names: minimal, protocol, or browser","If using a custom template, verify the relative/absolute path exists and is readable","Check the wrapped error for path resolution details"],"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"}