grafana/k6 · error

format of header must be header.k=v, received

Error message

format of header must be header.k=v, received %q

What it means

Returned while parsing K6_BROWSER_SCREENSHOTS_OUTPUT when a key containing 'header.' splits on '.' into something other than exactly 2 parts. Headers are encoded as header.<name>=<value>, so the key may have exactly one dot; extra dots (header..name, header.1.x) or a doubled dot produce this error.

Solutions

  1. Use exactly one dot in header keys: header.Authorization=Bearer xyz
  2. For header names that themselves contain a dot, replace the dot (e.g. dash) or encode it — the parser cannot carry a literal extra '.' in the name
  3. Re-check the segment quoting the received value shown in the error

Example fix

# before
export K6_BROWSER_SCREENSHOTS_OUTPUT='url=https://h/,header..auth=token'
# after
export K6_BROWSER_SCREENSHOTS_OUTPUT='url=https://h/,header.auth=token'
Defensive patterns

Strategy: validation

Validate before calling

const v = process.env.K6_BROWSER_SCREENSHOTS_OUTPUT ?? '';
if (v) {
  const bad = v.split(',').filter(p => p.startsWith('header.') && p.split('=')[0].split('.').length !== 2);
  if (bad.length) throw new Error(`header keys must be header.<name> with exactly one dot: ${bad.join(' | ')}`);
}

Prevention

When it happens

Trigger: K6_BROWSER_SCREENSHOTS_OUTPUT containing 'header..asd=a' or 'header.x.custom=v' — keys where the literal 'header.' is followed by another dotted component.

Common situations: Trying to send a header whose intended name contains a dot (e.g. 'X-Custom.Sub') — the encoding scheme cannot express dotted header names; hand-editing the variable and slipping an extra dot.

Related errors


AI-assisted analysis of grafana/k6@01ffac6f24 (2026-08-18). Data as JSON: /api/errors/d97a47e0a160e92b. Report an issue: GitHub.

Appendix: source

Thrown at internal/js/modules/k6/browser/browser/file_persister.go:68

		kv := strings.Split(s, "=")
		if len(kv) != 2 {
			return presignedURLConfig{}, fmt.Errorf("format of value must be k=v, received %q", s)
		}

		k := kv[0]
		v := kv[1]

		// A key with "header." means that the header name is encoded in the
		// key, separated by a ".". Split the header on "." to retrieve the
		// header name. The header value should be present in v from the previous
		// split.
		var hv, hk string
		if strings.Contains(k, "header.") {
			hv = v

			hh := strings.Split(k, ".")
			if len(hh) != 2 {
				return presignedURLConfig{}, fmt.Errorf("format of header must be header.k=v, received %q", s)
			}

			k = hh[0]
			hk = hh[1]

			if hk == "" {
				return presignedURLConfig{}, fmt.Errorf("empty header key, received %q", s)
			}
		}

		switch k {
		case "url":
			u, err := url.ParseRequestURI(v)
			if err != nil && u.Scheme != "" && u.Host != "" {
				return presignedURLConfig{}, fmt.Errorf("invalid url %q", s)
			}
			presignedURL.getterURL = v
		case "basePath":

View on GitHub (pinned to 01ffac6f24)