grafana/k6 · error

parsing fill options

Error message

parsing fill options: %w

What it means

Thrown synchronously when the options argument to locator.fill() fails to parse. The mapping (locator_mapping.go:192-196) builds common.FrameFillOptions and wraps Parse failures as "parsing fill options: %w". Parse delegates to ElementHandleBaseOptions.Parse, which reads force, noWaitAfter and timeout with coercing accessors and returns nil on ordinary values — so the wrapped error indicates sobek raised while enumerating or reading the options object (throwing getter, Proxy trap, or throwing implicit conversion).

Solutions

  1. Pass a plain literal: locator.fill('text', { timeout: 5000, force: true })
  2. Precompute dynamic values; avoid getters/Proxies on options
  3. Keep keys to the documented set (force, noWaitAfter, timeout, strict) as plain data
  4. try/catch the call and report which option broke

Example fix

// before
await locator.fill(userInput, instrumentedOpts); // Proxy throws in get trap

// after
const { timeout, force } = instrumentedOpts; // destructure first
await locator.fill(userInput, { timeout, force });
Defensive patterns

Strategy: try-catch

Type guard

function isPlainFillOptions(o) {
  return o == null || (typeof o === 'object' &&
    (o.timeout === undefined || typeof o.timeout === 'number') &&
    (o.force === undefined || typeof o.force === 'boolean') &&
    (o.noWaitAfter === undefined || typeof o.noWaitAfter === 'boolean') &&
    (o.strict === undefined || typeof o.strict === 'boolean'));
}

Try / catch

try {
  await locator.fill(value, opts);
} catch (e) {
  throw new Error(`fill failed (ensure options are plain force/noWaitAfter/timeout/strict values): ${e}`);
}

Prevention

When it happens

Trigger: An options getter for force/noWaitAfter/timeout that raises; Proxy-wrapped options with throwing get/ownKeys traps; a timeout object whose toPrimitive/valueOf throws during ToInteger.

Common situations: Page objects exposing lazily-validated config getters; logging Proxies applied to all call arguments; passing a class instance with accessors instead of a literal.

Related errors


AI-assisted analysis of grafana/k6@8d06114777 (2026-09-14). Data as JSON: /api/errors/47a582e59ffd3979. Report an issue: GitHub.

Appendix: source

Thrown at internal/js/modules/k6/browser/browser/locator_mapping.go:195

			}
			return promise(vu, func() (any, error) {
				return lo.IsInViewport(copts) //nolint:wrapcheck
			}), nil
		},
		"isVisible": func() *sobek.Promise {
			return promise(vu, func() (any, error) {
				return lo.IsVisible() //nolint:wrapcheck
			})
		},
		"isHidden": func() *sobek.Promise {
			return promise(vu, func() (any, error) {
				return lo.IsHidden() //nolint:wrapcheck
			})
		},
		"fill": func(value string, opts sobek.Value) (*sobek.Promise, error) {
			copts, err := parseFrameFillOptions(rt, opts, lo.Timeout())
			if err != nil {
				return nil, fmt.Errorf("parsing fill options: %w", err)
			}
			return promise(vu, func() (any, error) {
				return nil, lo.Fill(value, copts) //nolint:wrapcheck
			}), nil
		},
		"filter": func(opts sobek.Value) mapping {
			return mapLocator(vu, lo.Filter(&common.LocatorFilterOptions{
				LocatorOptions: parseLocatorOptions(rt, opts),
			}))
		},
		"first": func() *sobek.Object {
			ml := mapLocator(vu, lo.First())
			return rt.ToValue(ml).ToObject(rt)
		},
		"focus": func(opts sobek.Value) (*sobek.Promise, error) {
			copts := common.NewFrameBaseOptions(lo.Timeout())
			if err := parseFrameBaseOptions(copts, rt, opts); err != nil {
				return nil, fmt.Errorf("parsing focus options: %w", err)

View on GitHub (pinned to 8d06114777)