{"record":{"id":"67c8b23dc91d26fa","repo":"grafana/k6","slug":"name-q-is-invalid","errorCode":null,"errorMessage":"name %q is invalid","messagePattern":"name %q is invalid","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/page.go","lineNumber":446,"sourceCode":"\t// The patterns to match against.\n\tMatches []Match `js:\"matches\"`\n}\n\n// Match contains the fields that will be used to match against metric tags\n// that are about to be emitted.\ntype Match struct {\n\t// This is a regex that will be compared against the existing url tag.\n\tURLRegEx string `js:\"url\"`\n\t// This is the request method to match on.\n\tMethod string `js:\"method\"`\n}\n\n// Tag will find the first match given the URLTagPatterns and the URL from\n// the metric tag and update the name field.\nfunc (e *MetricEvent) Tag(rm RegExMatcher, matches TagMatches) error {\n\tname := strings.TrimSpace(matches.TagName)\n\tif name == \"\" {\n\t\treturn fmt.Errorf(\"name %q is invalid\", matches.TagName)\n\t}\n\n\tfor _, m := range matches.Matches {\n\t\t// Validate the request method type if it has been assigned in a Match.\n\t\tmethod := strings.TrimSpace(m.Method)\n\t\tif method != \"\" {\n\t\t\tmethod = strings.ToUpper(method)\n\t\t\tswitch method {\n\t\t\tcase http.MethodGet, http.MethodPost, http.MethodPut, http.MethodDelete, http.MethodPatch,\n\t\t\t\thttp.MethodHead, http.MethodOptions, http.MethodConnect, http.MethodTrace:\n\t\t\tdefault:\n\t\t\t\treturn fmt.Errorf(\"method %q is invalid\", m.Method)\n\t\t\t}\n\n\t\t\tif method != e.method {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}","sourceCodeStart":428,"sourceCodeEnd":464,"githubUrl":"https://github.com/grafana/k6/blob/3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee/internal/js/modules/k6/browser/common/page.go#L428-L464","documentation":"Validation guard in MetricEvent.Tag: the tag name supplied for renaming emitted browser metrics is empty after trimming. The offending input is matches.TagName in the metricEventPatterns match group from the browser context options.","triggerScenarios":"Thrown at internal/js/modules/k6/browser/common/page.go:444 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Provide a non-empty tagName in each metricEventPatterns match entry","Avoid whitespace-only tag names in options","Validate metricEventPatterns from external input before context creation"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}