{"record":{"id":"3e1b5569a553c214","repo":"grafana/k6","slug":"parsing-hover-options-w-3e1b55","errorCode":null,"errorMessage":"parsing hover options: %w","messagePattern":"parsing hover options: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/browser/locator_mapping.go","lineNumber":401,"sourceCode":"\t\t\t}\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\treturn nil, lo.PressSequentially(text, copts) //nolint:wrapcheck\n\t\t\t}), nil\n\t\t},\n\n\t\t\"type\": func(text string, opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tcopts, err := parseFrameTypeOptions(rt, opts, lo.Timeout())\n\t\t\tif 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, lo.Type(text, copts) //nolint:wrapcheck\n\t\t\t}), nil\n\t\t},\n\t\t\"hover\": func(opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tcopts, err := parseFrameHoverOptions(rt, opts, lo.Timeout())\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing hover options: %w\", err)\n\t\t\t}\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\treturn nil, lo.Hover(copts) //nolint:wrapcheck\n\t\t\t}), nil\n\t\t},\n\t\t\"tap\": func(opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tcopts, err := parseFrameTapOptions(rt, opts, lo.DefaultTimeout())\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing locator tap options: %w\", err)\n\t\t\t}\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\treturn nil, lo.Tap(copts) //nolint:wrapcheck\n\t\t\t}), nil\n\t\t},\n\t\t\"dispatchEvent\": func(typ string, eventInit, opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tpopts, err := parseFrameDispatchEventOptions(rt, opts, lo.DefaultTimeout())\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing locator dispatch event options: %w\", err)","sourceCodeStart":383,"sourceCodeEnd":419,"githubUrl":"https://github.com/grafana/k6/blob/8d06114777191d21ef885d05c5f8aa9e1ed838ae/internal/js/modules/k6/browser/browser/locator_mapping.go#L383-L419","documentation":"Thrown synchronously when the options argument to locator.hover(opts) fails to parse. The mapping (locator_mapping.go:397-401) builds common.FrameHoverOptions and wraps Parse failures as \"parsing hover options: %w\". Parse runs ElementHandleHoverOptions.Parse (element_handle_options.go:377-395): after the base keys, it exports \"position\" to map[string]float64 and \"modifiers\" to []string — these two ExportTo conversions are the only value-level failures, e.g. position: {x:'10'} with string coordinates or modifiers: 'Shift' as a bare string.","triggerScenarios":"locator.hover({ position: { x: '10', y: 20 } }) with string coordinates; position given as a string or number instead of {x,y}; modifiers: 'Shift' instead of ['Shift']; modifiers: [1,2]; plus throwing getters/Proxy traps on any key.","commonSituations":"Hovering at coordinates read from data attributes or boundingBox math that produce strings; passing Playwright-style modifiers as a string; computed position variables that end up undefined/null-shaped; instrumentation Proxies over options.","solutions":["Pass position as { x: <number>, y: <number> } relative to the element's top-left, with Number()-converted values","Pass modifiers as an array of strings from 'Alt', 'Control', 'Meta', 'Shift'","Keep other keys (force, noWaitAfter, timeout, trial, strict) as plain data","try/catch the call and validate position/modifiers beforehand when values are computed"],"exampleFix":"// before\nconst box = await locator.boundingBox();\nawait locator.hover({ position: { x: `${box.width}/2`, y: box.height / 2 } }); // template string\n\n// after\nconst box = await locator.boundingBox();\nawait locator.hover({ position: { x: box.width / 2, y: box.height / 2 } });","handlingStrategy":"validation","validationCode":"function assertHoverOptions(opts) {\n  if (opts == null) return;\n  if (typeof opts !== 'object' || Array.isArray(opts)) throw new TypeError('hover options must be an object');\n  if (opts.position != null) {\n    const p = opts.position;\n    if (typeof p !== 'object' || !Number.isFinite(p.x) || !Number.isFinite(p.y))\n      throw new TypeError(`position must be { x: number, y: number }, got ${JSON.stringify(p)}`);\n  }\n  if (opts.modifiers != null) {\n    if (!Array.isArray(opts.modifiers) || opts.modifiers.some(m => typeof m !== 'string'))\n      throw new TypeError('modifiers must be an array of strings');\n  }\n}\nassertHoverOptions(opts);\nawait locator.hover(opts);","typeGuard":"function isHoverOptions(o) {\n  if (o == null) return true;\n  if (typeof o !== 'object') return false;\n  const pOk = o.position === undefined ||\n    (typeof o.position === 'object' && Number.isFinite(o.position.x) && Number.isFinite(o.position.y));\n  const mOk = o.modifiers === undefined ||\n    (Array.isArray(o.modifiers) && o.modifiers.every(m => typeof m === 'string'));\n  return pOk && mOk;\n}","tryCatchPattern":"try { await locator.hover(opts); } catch (e) { if (String(e).includes('parsing hover options')) throw new Error(`bad hover position/modifiers: ${JSON.stringify(opts)}`); throw e; }","preventionTips":["Always Number()-convert coordinates from boundingBox math or data attributes","Pass modifiers as ['Shift'], never a bare string","Keep position keys exactly x and y, both finite numbers"],"tags":["k6","browser","locator","hover","options","position","modifiers"],"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"}