grafana/k6 · error

invalid option

Error message

invalid option %q

What it means

Returned while parsing K6_BROWSER_SCREENSHOTS_OUTPUT when a segment's key is not one of the three recognized options: url, basePath, or header.<name>. The switch's default branch rejects everything else, quoting the offending key. This is the typical typo error — e.g. 'ulr=' instead of 'url='.

Solutions

  1. Correct the key to one of url, basePath, or header.<name> — the error message shows the exact invalid key
  2. Copy the canonical example: url=https://127.0.0.1/,basePath=/screenshots,header.1=a
  3. Remove options the remote endpoint does not need

Example fix

# before
export K6_BROWSER_SCREENSHOTS_OUTPUT='ulr=https://h/,path=/shots'
# after
export K6_BROWSER_SCREENSHOTS_OUTPUT='url=https://h/,basePath=/shots'
Defensive patterns

Strategy: validation

Validate before calling

const v = process.env.K6_BROWSER_SCREENSHOTS_OUTPUT ?? '';
if (v) {
  const allowed = /^(url|basePath|header\.[^,.]+)$/;
  const bad = v.split(',').filter(p => !allowed.test(p.split('=')[0]));
  if (bad.length) throw new Error(`unknown options ${bad.join(' | ')}; allowed keys: url, basePath, header.<name>`);
}

Prevention

When it happens

Trigger: K6_BROWSER_SCREENSHOTS_OUTPUT containing 'ulr=https://h/' (typo), 'path=/shots' (should be basePath), or 'headers.1=a' (plural — should be header.1).

Common situations: Hand-typing the variable in a shell or CI pipeline; mixing up k6's key names with those of another tool; pluralizing 'header'/'basePath'.

Related errors


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

Appendix: source

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

			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":
			presignedURL.basePath = v
		case "header":
			presignedURL.headers[hk] = hv
		default:
			return presignedURLConfig{}, fmt.Errorf("invalid option %q", k)
		}
	}

	if presignedURL.getterURL == "" {
		return presignedURLConfig{}, errors.New("missing required url")
	}

	return presignedURL, nil
}

View on GitHub (pinned to 01ffac6f24)