{"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":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/browser/locator_mapping.go","lineNumber":359,"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, err := parseFrameInputValueOptions(rt, opts, lo.Timeout())\n\t\t\tif 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, err := parseFrameSelectOptionOptions(rt, opts, lo.Timeout())\n\t\t\tif 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, err := parseFramePressOptions(rt, opts, lo.Timeout())\n\t\t\tif 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":341,"sourceCodeEnd":377,"githubUrl":"https://github.com/grafana/k6/blob/8d06114777191d21ef885d05c5f8aa9e1ed838ae/internal/js/modules/k6/browser/browser/locator_mapping.go#L341-L377","documentation":"Thrown synchronously when the options (second) argument to locator.selectOption(values, opts) fails to parse. The mapping (locator_mapping.go:356-360) builds common.FrameSelectOptionOptions and wraps Parse failures as \"parsing select option options: %w\". Parse delegates to ElementHandleBaseOptions.Parse (force/noWaitAfter/timeout coercions) plus parseStrict, none of which fail on ordinary mistyped values — so a real occurrence means sobek raised reading the object: a throwing getter, a Proxy trap, or a throwing implicit conversion.","triggerScenarios":"An options getter for timeout/force that raises; Proxy options with throwing get/ownKeys traps; a timeout whose valueOf throws during ToInteger. Note this is the options object, not the values argument (values errors surface as \"parsing select option values\").","commonSituations":"Porting Playwright selectOption calls and building the options object from instrumented config; tracing harnesses that proxy arguments; accessor-rich page-object options.","solutions":["Pass a plain literal: locator.selectOption('blue', { timeout: 5000 })","Compute option values before the call; avoid getters/Proxies","Distinguish this error from \"parsing select option values\" — the first is opts, the second is the values argument","try/catch the call and report the failing argument"],"exampleFix":"// before\nawait locator.selectOption(values, optsProxy); // optsProxy get trap throws\n\n// after\nconst { timeout, force } = optsProxy;\nawait locator.selectOption(values, { timeout, force });","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isPlainSelectOptions(o) {\n  return o == null || (typeof o === 'object' &&\n    (o.timeout === undefined || typeof o.timeout === 'number') &&\n    (o.force === undefined || typeof o.force === 'boolean') &&\n    (o.noWaitAfter === undefined || typeof o.noWaitAfter === 'boolean') &&\n    (o.strict === undefined || typeof o.strict === 'boolean'));\n}","tryCatchPattern":"try {\n  await locator.selectOption(values, opts);\n} catch (e) {\n  if (String(e).includes('parsing select option options'))\n    throw new Error(`bad selectOption opts (2nd arg): ${JSON.stringify(opts)}`);\n  if (String(e).includes('parsing select option values'))\n    throw new Error(`bad selectOption values (1st arg): ${JSON.stringify(values)}`);\n  throw e;\n}","preventionTips":["Distinguish the two selectOption parse errors: options vs values","Keep opts a plain literal","Do not wrap the options argument in Proxies or getters"],"tags":["k6","browser","locator","selectoption","options"],"backgroundTag":"invalid-options-object","analyzedSha":"8d06114777191d21ef885d05c5f8aa9e1ed838ae","analyzedAt":"2026-09-14T20:10:14.619Z","contentChangedAt":"2026-09-14T20:10:14.619Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}