grafana/k6 · error

parsing input value options: %w

Error message

parsing input value options: %w

What it means

Thrown when locator.inputValue(opts) cannot parse its options into FrameInputValueOptions (embeds FrameBaseOptions: strict boolean, timeout number in ms). The mapping wraps the cause as 'parsing input value options: %w'. The parse happens synchronously before the promise is created, so the error rejects immediately without touching the browser.

Source

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

			copts := common.NewFrameTextContentOptions(lo.Timeout())
			if err := copts.Parse(vu.Context(), opts); err != nil {
				return nil, fmt.Errorf("parsing text content options: %w", err)
			}
			return promise(vu, func() (any, error) {
				s, ok, err := lo.TextContent(copts)
				if err != nil {
					return nil, err //nolint:wrapcheck
				}
				if !ok {
					return nil, nil
				}
				return s, nil
			}), nil
		},
		"inputValue": func(opts sobek.Value) (*sobek.Promise, error) {
			copts := common.NewFrameInputValueOptions(lo.Timeout())
			if err := copts.Parse(vu.Context(), opts); err != nil {
				return nil, fmt.Errorf("parsing input value options: %w", err)
			}
			return promise(vu, func() (any, error) {
				return lo.InputValue(copts) //nolint:wrapcheck
			}), nil
		},
		"selectOption": func(values sobek.Value, opts sobek.Value) (*sobek.Promise, error) {
			copts := common.NewFrameSelectOptionOptions(lo.Timeout())
			if err := copts.Parse(vu.Context(), opts); err != nil {
				return nil, fmt.Errorf("parsing select option options: %w", err)
			}
			convValues, err := ConvertSelectOptionValues(vu.Runtime(), values)
			if err != nil {
				return nil, fmt.Errorf("parsing select option values: %w", err)
			}
			return promise(vu, func() (any, error) {
				return lo.SelectOption(convValues, copts) //nolint:wrapcheck
			}), nil
		},

View on GitHub (pinned to 93accf6570)

Solutions

  1. Call inputValue() bare or with { timeout: <number-ms> }
  2. Use numbers, not duration strings, for timeout
  3. Keep the options object a plain literal with only strict/timeout keys
  4. Set default timeout on the locator once instead

Example fix

// before
const v = await page.locator('input[name=q]').inputValue('5s');

// after
const v = await page.locator('input[name=q]').inputValue({ timeout: 5000 });
Defensive patterns

Strategy: validation

Validate before calling

function assertBaseOpts(method, opts) {
  if (opts === null || opts === undefined) return;
  if (typeof opts !== 'object' || Array.isArray(opts)) {
    throw new TypeError(`${method} options must be a plain object, got ${typeof opts}`);
  }
  if ('timeout' in opts && typeof opts.timeout !== 'number') {
    throw new TypeError(`${method} timeout must be a number (ms)`);
  }
}
assertBaseOpts('inputValue', opts);

Type guard

function isLocatorBaseOptions(v) {
  if (v === null || v === undefined) return true;
  if (typeof v !== 'object' || Array.isArray(v)) return false;
  return (v.timeout === undefined || typeof v.timeout === 'number') &&
         (v.strict === undefined || typeof v.strict === 'boolean');
}

Try / catch

try {
  const v = await locator.inputValue(opts);
} catch (e) {
  if (/parsing input value options/.test(String(e.message))) {
    throw new Error(`Bad inputValue options: ${JSON.stringify(opts)}`);
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling locator.inputValue('5s') or inputValue(5000) — scalar in the opts slot; passing a non-plain-object (array, function) as options; wrong-typed timeout under strict parsers.

Common situations: Reading form field values in load tests and passing durations as strings; argument slips like inputValue({ 'timeout': '1s' }); sharing one options constant across methods with different accepted keys.

Related errors


AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15). Data as JSON: /api/errors/d238db238795d8f6. Report an issue: GitHub.