{"record":{"id":"1f88f6ca3e106ae2","repo":"grafana/k6","slug":"parsing-setchecked-options-w","errorCode":null,"errorMessage":"parsing setChecked options: %w","messagePattern":"parsing setChecked options: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/browser/element_handle_mapping.go","lineNumber":231,"sourceCode":"\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 := parseElementHandleBaseOptions(popts, rt, 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, err := parseElementHandleSetCheckedOptions(rt, opts, eh.DefaultTimeout())\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing setChecked options: %w\", err)\n\t\t\t}\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\treturn nil, eh.SetChecked(checked, popts) //nolint:wrapcheck\n\t\t\t}), nil\n\t\t},\n\t\t\"setInputFiles\": func(files sobek.Value, opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tpopts, err := parseElementHandleSetInputFilesOptions(rt, opts, eh.DefaultTimeout())\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing setInputFiles options: %w\", err)\n\t\t\t}\n\t\t\tvar pfiles common.Files\n\t\t\tif err := pfiles.Parse(vu.Context(), files); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing setInputFiles parameter: %w\", err)\n\t\t\t}\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\treturn nil, eh.SetInputFiles(&pfiles, popts) //nolint:wrapcheck\n\t\t\t}), nil\n\t\t},","sourceCodeStart":213,"sourceCodeEnd":249,"githubUrl":"https://github.com/grafana/k6/blob/3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee/internal/js/modules/k6/browser/browser/element_handle_mapping.go#L213-L249","documentation":"Thrown synchronously (before the promise is created) when ElementHandle.setChecked cannot parse its options object into ElementHandleSetCheckedOptions. The underlying parser (common/element_handle_options.go) coerces force/noWaitAfter/timeout/strict and silently ignores unknown keys, so the only realistic failure is the position field failing to export to a map[string]float64. In practice this means position was not a plain object with numeric values.","triggerScenarios":"setChecked(true, {position: 'center'}), setChecked(true, {position: 10}), or setChecked(true, {position: {x: '10px', y: 20}}) — anything where position is not an object of number-valued keys x/y.","commonSituations":"Porting Playwright scripts that compute click positions as strings or CSS pixel values; building the options object dynamically (from JSON fixtures or env vars) so position ends up a string, number, or array; misunderstanding position as taking an element-relative keyword like 'center'.","solutions":["Pass position as numeric offsets from the element's top-left corner: {position: {x: 100, y: 50}}","Omit position entirely to act on the element's default center point","If options come from a variable, verify typeof opts.position === 'object' before the call"],"exampleFix":"// before\nawait handle.setChecked(true, { position: 'center' });\n// after\nawait handle.setChecked(true, { position: { x: 100, y: 50 } });","handlingStrategy":"try-catch","validationCode":"const validPos = (p) => p == null ||\n  (typeof p === 'object' && !Array.isArray(p) && Number.isFinite(p.x) && Number.isFinite(p.y));\nif (!validPos(opts.position)) {\n  throw new Error(`invalid position ${JSON.stringify(opts.position)}; expected {x: number, y: number}`);\n}\nawait handle.setChecked(true, opts);","typeGuard":"function isPointerPosition(v) {\n  return v == null ||\n    (typeof v === 'object' && !Array.isArray(v) &&\n      Number.isFinite(v.x) && Number.isFinite(v.y));\n}","tryCatchPattern":"try {\n  await handle.setChecked(true, opts);\n} catch (e) {\n  if (String(e).includes('parsing setChecked options')) {\n    // opts.position has the wrong shape; fix it and retry once\n    delete opts.position;\n    await handle.setChecked(true, opts);\n  } else { throw e; }\n}","preventionTips":["Always express position as numeric {x, y} offsets in milliseconds-free plain numbers","Type-check option objects built from fixtures, env vars, or interpolated data before passing them","Remember unknown option keys are silently ignored — typos never raise this error, so verify key names against the k6 browser API docs"],"tags":["k6","browser","element-handle","setchecked","options"],"backgroundTag":"options-validation-failed","analyzedSha":"3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee","analyzedAt":"2026-09-14T20:10:14.619Z","contentChangedAt":"2026-09-14T20:10:14.619Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}