{"record":{"id":"e2769843cfb23683","repo":"grafana/k6","slug":"parsing-mouse-up-options-w","errorCode":null,"errorMessage":"parsing mouse up options: %w","messagePattern":"parsing mouse up options: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/browser/mouse_mapping.go","lineNumber":46,"sourceCode":"\t\t\t\treturn nil, fmt.Errorf(\"parsing mouse double click options: %w\", err)\n\t\t\t}\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\treturn nil, m.DblClick(x, y, popts) //nolint:wrapcheck\n\t\t\t}), nil\n\t\t},\n\t\t\"down\": func(opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tpopts, err := parseMouseDownUpOptions(rt, opts)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing mouse down options: %w\", err)\n\t\t\t}\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\treturn nil, m.Down(popts) //nolint:wrapcheck\n\t\t\t}), nil\n\t\t},\n\t\t\"up\": func(opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tpopts, err := parseMouseDownUpOptions(rt, opts)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing mouse up options: %w\", err)\n\t\t\t}\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\treturn nil, m.Up(popts) //nolint:wrapcheck\n\t\t\t}), nil\n\t\t},\n\t\t\"move\": func(x float64, y float64, opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tpopts, err := parseMouseMoveOptions(rt, opts)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing mouse move options: %w\", err)\n\t\t\t}\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\treturn nil, m.Move(x, y, popts) //nolint:wrapcheck\n\t\t\t}), nil\n\t\t},\n\t}\n}\n\n// parseMouseClickOptions parses the mouse click options from a Sobek value.","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/js/modules/k6/browser/browser/mouse_mapping.go#L28-L64","documentation":"Thrown by mouse.up(options) when parseMouseDownUpOptions fails — the same parser as mouse.down (browser/mouse_mapping.go:124-145). It accepts 'button' (string) and 'clickCount' (integer); a non-integer clickCount or non-object options value aborts the release before the CDP input event is sent, leaving a pressed button un-released for that call.","triggerScenarios":"page.mouse().up({ clickCount: '1' }) or { clickCount: 1.5 } in a press-move-release drag sequence; sharing one options object between down and up calls where the count was coerced to string upstream.","commonSituations":"Drag-and-drop helper functions that take options from callers; count values round-tripped through JSON; mismatches where down() succeeded with an integer but up() received the string variant of the same config.","solutions":["Pass an integer: page.mouse().up({ clickCount: 1 }) or no options.","Normalize once and share the normalized object between down and up.","Coerce at the boundary: const count = Number(raw); if (!Number.isInteger(count)) throw ...","Keep the up options structurally identical to the down options you used."],"exampleFix":"// before\nawait page.mouse().down();\nawait page.mouse().move(100, 100);\nawait page.mouse().up({ clickCount: cfg.clicks }); // \"1\"\n\n// after\nconst count = Number(cfg.clicks) || 1;\nawait page.mouse().down();\nawait page.mouse().move(100, 100);\nawait page.mouse().up({ clickCount: count });","handlingStrategy":"validation","validationCode":"const count = raw == null ? undefined : Number(raw);\nif (count != null && !Number.isInteger(count)) throw new Error(`clickCount must be an integer, got ${raw}`);\nawait page.mouse().down({ clickCount: count });\nawait page.mouse().up({ clickCount: count });","typeGuard":"function isDownUpOptions(o) {\n  if (o == null) return true;\n  if (typeof o !== 'object') return false;\n  return (o.clickCount == null || Number.isInteger(o.clickCount)) && (o.button == null || typeof o.button === 'string');\n}","tryCatchPattern":"try { await page.mouse().up(opts); } catch (e) { if (/parsing mouse up options|clickCount must be an integer/.test(e.message)) { await page.mouse().up({ clickCount: parseInt(opts.clickCount, 10) }); } else throw e; }","preventionTips":["Normalize clickCount once and reuse the same value for down and up.","Coerce counts from data sources with Number() and an is-integer guard.","Keep press/release sequences in one helper so options cannot drift apart."],"tags":["k6","browser","mouse","mouse-up","options-parsing"],"backgroundTag":"invalid-options-argument","analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}