grafana/k6 · error

name is invalid

Error message

name %q is invalid

What it means

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.

Solutions

  1. Provide a non-empty tagName in each metricEventPatterns match entry
  2. Avoid whitespace-only tag names in options
  3. Validate metricEventPatterns from external input before context creation
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/js/modules/k6/browser/common/page.go:444 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of grafana/k6@3fcf5388d7 (2026-08-18). Data as JSON: /api/errors/67c8b23dc91d26fa. Report an issue: GitHub.

Appendix: source

Thrown at internal/js/modules/k6/browser/common/page.go:446

	// The patterns to match against.
	Matches []Match `js:"matches"`
}

// Match contains the fields that will be used to match against metric tags
// that are about to be emitted.
type Match struct {
	// This is a regex that will be compared against the existing url tag.
	URLRegEx string `js:"url"`
	// This is the request method to match on.
	Method string `js:"method"`
}

// Tag will find the first match given the URLTagPatterns and the URL from
// the metric tag and update the name field.
func (e *MetricEvent) Tag(rm RegExMatcher, matches TagMatches) error {
	name := strings.TrimSpace(matches.TagName)
	if name == "" {
		return fmt.Errorf("name %q is invalid", matches.TagName)
	}

	for _, m := range matches.Matches {
		// Validate the request method type if it has been assigned in a Match.
		method := strings.TrimSpace(m.Method)
		if method != "" {
			method = strings.ToUpper(method)
			switch method {
			case http.MethodGet, http.MethodPost, http.MethodPut, http.MethodDelete, http.MethodPatch,
				http.MethodHead, http.MethodOptions, http.MethodConnect, http.MethodTrace:
			default:
				return fmt.Errorf("method %q is invalid", m.Method)
			}

			if method != e.method {
				continue
			}
		}

View on GitHub (pinned to 3fcf5388d7)