{"record":{"id":"7d1c81d5ca0c84a7","repo":"grafana/k6","slug":"parsing-uncheck-options-w","errorCode":null,"errorMessage":"parsing uncheck options: %w","messagePattern":"parsing uncheck options: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/browser/element_handle_mapping.go","lineNumber":276,"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})\n\t\t},\n\t\t\"type\": func(text string, opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tpopts := common.NewElementHandleTypeOptions(eh.DefaultTimeout())\n\t\t\tif err := popts.Parse(vu.Context(), opts); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing type options: %w\", err)\n\t\t\t}\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\treturn nil, eh.Type(text, popts) //nolint:wrapcheck\n\t\t\t}), nil\n\t\t},\n\t\t\"uncheck\": func(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 uncheck options: %w\", err)\n\t\t\t}\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\treturn nil, eh.Uncheck(popts) //nolint:wrapcheck\n\t\t\t}), nil\n\t\t},\n\t\t\"waitForElementState\": func(state string, opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tpopts := common.NewElementHandleWaitForElementStateOptions(eh.DefaultTimeout())\n\t\t\tif err := popts.Parse(vu.Context(), opts); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing waitForElementState options: %w\", err)\n\t\t\t}\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\treturn nil, eh.WaitForElementState(state, popts) //nolint:wrapcheck\n\t\t\t}), nil\n\t\t},\n\t\t\"waitForSelector\": func(selector string, opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tpopts := common.NewFrameWaitForSelectorOptions(eh.DefaultTimeout())\n\t\t\tif err := popts.Parse(vu.Context(), opts); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing waitForSelector %q options: %w\", selector, err)","sourceCodeStart":258,"sourceCodeEnd":294,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/browser/element_handle_mapping.go#L258-L294","documentation":"Thrown synchronously by ElementHandle.uncheck() when its options fail to parse. uncheck reuses ElementHandleSetCheckedOptions (base-pointer options plus strict), and in common/element_handle_options.go the only Parse step that can return an error is exporting 'position' to map[string]float64. As elsewhere in the mapping, the (nil, error) return surfaces as a synchronous JS exception, not a promise rejection.","triggerScenarios":"el.uncheck({ position: 'center' }), { position: { x: 5, y: '5' } }, or position as an array/number. strict/force/noWaitAfter/timeout are coercions and never trigger this.","commonSituations":"Sharing an options object between setChecked/check/uncheck call sites where one stored position as a string; coordinates read from external fixtures without numeric conversion.","solutions":["Pass position as { x: <number>, y: <number> } or omit it to use the element center","Normalize coordinates once with Number() and Number.isFinite validation","Guard all pointer-action options with a shared isPosition helper","Catch with try/catch around the call itself"],"exampleFix":"// before\nawait el.uncheck({ position: [4, 4] });\n\n// after\nawait el.uncheck({ position: { x: 4, y: 4 } });","handlingStrategy":"type-guard","validationCode":"const p = opts?.position;\nif (p !== undefined && (typeof p !== 'object' || Array.isArray(p) ||\n    !Number.isFinite(Number(p.x)) || !Number.isFinite(Number(p.y)))) {\n  throw new Error('uncheck(): position must be { x: number, y: number }');\n}","typeGuard":"function isUncheckOpts(o) {\n  if (o == null) return true;\n  const posOk = o.position === undefined ||\n    (typeof o.position === 'object' && !Array.isArray(o.position) &&\n     Number.isFinite(Number(o.position.x)) && Number.isFinite(Number(o.position.y)));\n  const strictOk = o.strict === undefined || typeof o.strict === 'boolean';\n  return posOk && strictOk;\n}","tryCatchPattern":"try {\n  await el.uncheck(opts);\n} catch (e) {\n  if (/parsing uncheck options/.test(String(e.message))) {\n    console.log(`fix uncheck options: ${e.message}`);\n  } else throw e;\n}","preventionTips":["Only position can fail parsing; strict/force/noWaitAfter/timeout coerce leniently","Omit position to uncheck at the element center; that is the common case","Catch synchronously with try/catch around the call"],"tags":["k6","browser","element-handle","uncheck","option-parsing"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}