{"record":{"id":"fdd99620ae370401","repo":"grafana/k6","slug":"parsing-selectoption-options-w","errorCode":null,"errorMessage":"parsing selectOption options: %w","messagePattern":"parsing selectOption options: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/browser/element_handle_mapping.go","lineNumber":206,"sourceCode":"\t\t\t}), nil\n\t\t},\n\t\t\"scrollIntoViewIfNeeded\": func(opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tpopts := common.NewElementHandleBaseOptions(eh.DefaultTimeout())\n\t\t\tif err := popts.Parse(vu.Context(), opts); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing scrollIntoViewIfNeeded options: %w\", err)\n\t\t\t}\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\treturn nil, eh.ScrollIntoViewIfNeeded(popts) //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\tconvValues, err := ConvertSelectOptionValues(vu.Runtime(), values)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing select options values: %w\", err)\n\t\t\t}\n\t\t\tpopts := common.NewElementHandleBaseOptions(eh.DefaultTimeout())\n\t\t\tif err := popts.Parse(vu.Context(), opts); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing selectOption options: %w\", err)\n\t\t\t}\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\treturn eh.SelectOption(convValues, popts) //nolint:wrapcheck\n\t\t\t}), nil\n\t\t},\n\t\t\"selectText\": func(opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tpopts := common.NewElementHandleBaseOptions(eh.DefaultTimeout())\n\t\t\tif err := popts.Parse(vu.Context(), opts); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing selectText options: %w\", err)\n\t\t\t}\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\treturn nil, eh.SelectText(popts) //nolint:wrapcheck\n\t\t\t}), nil\n\t\t},\n\t\t\"setChecked\": func(checked bool, opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tpopts := common.NewElementHandleSetCheckedOptions(eh.DefaultTimeout())\n\t\t\tif err := popts.Parse(vu.Context(), opts); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing setChecked options: %w\", err)","sourceCodeStart":188,"sourceCodeEnd":224,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/browser/element_handle_mapping.go#L188-L224","documentation":"Thrown synchronously by ElementHandle.selectOption() when the trailing options object fails to parse. It parses common.ElementHandleBaseOptions (force, noWaitAfter, timeout), whose Parse is lenient coercion and always returns nil in common/element_handle_options.go, so this wrap is defensive in current k6. Do not confuse it with error 409, which covers the values argument and fires for real type mismatches.","triggerScenarios":"In current code none: force/noWaitAfter/timeout coerce any value and unknown keys are ignored. Note that 'state' or other Playwright waitForSelector-style keys passed here are silently ignored, not rejected.","commonSituations":"Passing a timeout as '3s' (coerced to a wrong number rather than erroring); scripts written against old xk6-browser where the whole options object was structurally exported and could fail on incompatible field types.","solutions":["Keep the second argument to { force, noWaitAfter, timeout } with numeric milliseconds","Put selection values in the first argument, not the options object","Upgrade k6 if this message appears and retest with an empty options object","Check the wrapped cause after the colon for the failing field"],"exampleFix":"// before\nawait el.selectOption('blue', { timeout: '3s' });\n\n// after\nawait el.selectOption('blue', { timeout: 3000 });","handlingStrategy":"try-catch","validationCode":"const ALLOWED = new Set(['force', 'noWaitAfter', 'timeout']);\nconst bad = Object.keys(opts || {}).filter(k => !ALLOWED.has(k));\nif (bad.length) console.warn(`selectOption(): unsupported options ignored: ${bad.join(', ')}`);\nif (opts?.timeout !== undefined && !Number.isFinite(Number(opts.timeout))) {\n  throw new Error('selectOption(): timeout must be ms number');\n}","typeGuard":"function isSelectOpts(o) {\n  if (o == null) return true;\n  return (o.force === undefined || typeof o.force === 'boolean') &&\n         (o.noWaitAfter === undefined || typeof o.noWaitAfter === 'boolean') &&\n         (o.timeout === undefined || Number.isFinite(o.timeout));\n}","tryCatchPattern":"try {\n  await el.selectOption(values, opts);\n} catch (e) {\n  if (/parsing selectOption options/.test(String(e.message))) {\n    console.log(`fix selectOption options object: ${e.message}`);\n  } else throw e; // 'parsing select options values' means the FIRST argument is bad instead\n}","preventionTips":["Keep selection values in the first argument; the second argument only takes force/noWaitAfter/timeout","Distinguish the two error texts: 'select options values' = values argument, 'selectOption options' = options object","Current k6 cannot fail the options-object parse; occurrence signals an old binary"],"tags":["k6","browser","element-handle","select-option","option-parsing"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}