{"record":{"id":"84933e40de375139","repo":"grafana/k6","slug":"parsing-select-option-options-w-84933e","errorCode":null,"errorMessage":"parsing select option options: %w","messagePattern":"parsing select option options: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/browser/locator_mapping.go","lineNumber":358,"sourceCode":"\t\t\t\tif !ok {\n\t\t\t\t\treturn nil, nil\n\t\t\t\t}\n\t\t\t\treturn s, nil\n\t\t\t}), nil\n\t\t},\n\t\t\"inputValue\": func(opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tcopts := common.NewFrameInputValueOptions(lo.Timeout())\n\t\t\tif err := copts.Parse(vu.Context(), opts); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing input value options: %w\", err)\n\t\t\t}\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\treturn lo.InputValue(copts) //nolint:wrapcheck\n\t\t\t}), nil\n\t\t},\n\t\t\"selectOption\": func(values sobek.Value, opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tcopts := common.NewFrameSelectOptionOptions(lo.Timeout())\n\t\t\tif err := copts.Parse(vu.Context(), opts); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing select option options: %w\", err)\n\t\t\t}\n\t\t\tconvValues, err := ConvertSelectOptionValues(vu.Runtime(), values)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing select option values: %w\", err)\n\t\t\t}\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\treturn lo.SelectOption(convValues, copts) //nolint:wrapcheck\n\t\t\t}), nil\n\t\t},\n\t\t\"press\": func(key string, opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tcopts := common.NewFramePressOptions(lo.Timeout())\n\t\t\tif err := copts.Parse(vu.Context(), opts); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing press options: %w\", err)\n\t\t\t}\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\treturn nil, lo.Press(key, copts) //nolint:wrapcheck\n\t\t\t}), nil\n\t\t},","sourceCodeStart":340,"sourceCodeEnd":376,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/browser/locator_mapping.go#L340-L376","documentation":"Thrown when locator.selectOption(values, opts) cannot parse its second (options) argument into FrameSelectOptionOptions, which embeds ElementHandleBaseOptions (force, noWaitAfter booleans; timeout number in ms) plus a strict boolean. The mapping wraps the cause as 'parsing select option options: %w'. This is separate from the values argument error ('parsing select option values') — it only concerns the trailing options object.","triggerScenarios":"Calling locator.selectOption('blue', 'fast') or selectOption('blue', 30000) — a scalar in the opts slot; passing { timeout: '1s' } under strict parsing; passing a third positional argument where only two exist.","commonSituations":"Chaining selectOption with a timeout string copied from documentation examples; reusing click() options (with position/modifiers) that selectOption does not read; migrating from Playwright where option shapes differ slightly.","solutions":["Pass the options object as the second argument: selectOption('blue', { timeout: 5000 })","Keep only supported keys: force, noWaitAfter, strict, timeout (numeric ms)","Omit the second argument when defaults are fine","Verify argument order: values first, options second"],"exampleFix":"// before\nawait page.locator('select.color').selectOption('blue', '5s');\n\n// after\nawait page.locator('select.color').selectOption('blue', { timeout: 5000 });","handlingStrategy":"validation","validationCode":"function assertSelectOptionOpts(opts) {\n  if (opts === null || opts === undefined) return;\n  if (typeof opts !== 'object' || Array.isArray(opts)) {\n    throw new TypeError('selectOption options must be a plain object');\n  }\n  const okKeys = new Set(['force', 'noWaitAfter', 'strict', 'timeout']);\n  for (const k of Object.keys(opts)) {\n    if (!okKeys.has(k)) continue; // unknown keys are ignored by the parser\n    const t = typeof opts[k];\n    if (k === 'timeout' && t !== 'number') throw new TypeError('timeout must be a number (ms)');\n    if (k !== 'timeout' && t !== 'boolean') throw new TypeError(`${k} must be a boolean`);\n  }\n}","typeGuard":"function isSelectOptionOptions(v) {\n  if (v === null || v === undefined) return true;\n  if (typeof v !== 'object' || Array.isArray(v)) return false;\n  return (v.timeout === undefined || typeof v.timeout === 'number') &&\n         (v.force === undefined || typeof v.force === 'boolean') &&\n         (v.noWaitAfter === undefined || typeof v.noWaitAfter === 'boolean') &&\n         (v.strict === undefined || typeof v.strict === 'boolean');\n}","tryCatchPattern":"try {\n  await locator.selectOption(values, opts);\n} catch (e) {\n  if (/parsing select option options/.test(String(e.message))) {\n    throw new Error(`Bad selectOption options (second argument): ${JSON.stringify(opts)}`);\n  }\n  throw e;\n}","preventionTips":["Remember the signature: values first, options object second","Do not reuse click options (position/modifiers) for selectOption","Use numeric millisecond timeouts"],"tags":["k6","browser","locator","options","selectoption"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}