grafana/k6 · error

parsing grant permission options

Error message

parsing grant permission options: %w

What it means

Generic parse wrapper for browserContext.grantPermissions: the options sobek.Value passed as the second argument failed to decode into common.GrantPermissionsOptions via exportTo. The wrapped error identifies the malformed field (usually an unexpected type or unknown key).

Solutions

  1. Pass a plain options object with only expected keys, e.g. grantPermissions(['geolocation'], { origin: 'https://example.com' })
  2. Check field types against the browser module API docs
  3. Omit the options argument entirely if no options are needed
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/js/modules/k6/browser/browser/browser_context_mapping.go:86 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at internal/js/modules/k6/browser/browser/browser_context_mapping.go:86

		"clearPermissions": func() *sobek.Promise {
			return promise(vu, func() (any, error) {
				return nil, bc.ClearPermissions() //nolint:wrapcheck
			})
		},
		"close": func() *sobek.Promise {
			return promise(vu, func() (any, error) {
				return nil, bc.Close() //nolint:wrapcheck
			})
		},
		"cookies": func(urls ...string) *sobek.Promise {
			return promise(vu, func() (any, error) {
				return bc.Cookies(urls...) //nolint:wrapcheck
			})
		},
		"grantPermissions": func(permissions []string, opts sobek.Value) (*sobek.Promise, error) {
			popts, err := exportTo[common.GrantPermissionsOptions](vu.Runtime(), opts)
			if err != nil {
				return nil, fmt.Errorf("parsing grant permission options: %w", err)
			}
			return promise(vu, func() (any, error) {
				return nil, bc.GrantPermissions(permissions, popts)
			}), nil
		},
		"setDefaultNavigationTimeout": bc.SetDefaultNavigationTimeout,
		"setDefaultTimeout":           bc.SetDefaultTimeout,
		"setGeolocation": func(geolocation sobek.Value) (*sobek.Promise, error) {
			gl, err := exportTo[common.Geolocation](vu.Runtime(), geolocation)
			if err != nil {
				return nil, fmt.Errorf("parsing geo location: %w", err)
			}
			return promise(vu, func() (any, error) {
				return nil, bc.SetGeolocation(&gl)
			}), nil
		},
		"setHTTPCredentials": func(httpCredentials sobek.Value) (*sobek.Promise, error) {
			creds, err := exportTo[common.Credentials](rt, httpCredentials)

View on GitHub (pinned to 01ffac6f24)