{"record":{"id":"605b7e9ff400ed30","repo":"grafana/k6","slug":"parsing-locator-bounding-box-options-w","errorCode":null,"errorMessage":"parsing locator bounding box options: %w","messagePattern":"parsing locator bounding box options: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/browser/locator_mapping.go","lineNumber":37,"sourceCode":"\treturn mapping{\n\t\t\"all\": func() *sobek.Promise {\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\tall, err := lo.All()\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\n\t\t\t\tres := make([]mapping, len(all))\n\t\t\t\tfor i, el := range all {\n\t\t\t\t\tres[i] = mapLocator(vu, el)\n\t\t\t\t}\n\t\t\t\treturn res, nil\n\t\t\t})\n\t\t},\n\t\t\"boundingBox\": func(opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tpopts := common.NewFrameBaseOptions(lo.Timeout())\n\t\t\tif err := parseFrameBaseOptions(popts, rt, opts); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing locator bounding box options: %w\", err)\n\t\t\t}\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\tbox, err := lo.BoundingBox(popts)\n\t\t\t\t// We want to avoid errors when an element is not visible or detached and instead\n\t\t\t\t// opt to return a nil rectangle -- this matches Playwright's behaviour.\n\t\t\t\tif errors.Is(err, common.ErrElementNotVisible) || errors.Is(err, common.ErrElementNotAttachedToDOM) {\n\t\t\t\t\treturn nil, nil\n\t\t\t\t}\n\t\t\t\treturn box, err\n\t\t\t}), nil\n\t\t},\n\t\t\"clear\": func(opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tcopts, err := parseFrameFillOptions(rt, opts, lo.Timeout())\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing clear options: %w\", err)\n\t\t\t}\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\treturn nil, lo.Clear(copts) //nolint:wrapcheck","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/grafana/k6/blob/8d06114777191d21ef885d05c5f8aa9e1ed838ae/internal/js/modules/k6/browser/browser/locator_mapping.go#L19-L55","documentation":"Thrown while parsing the options object of locator.boundingBox(options) (browser/locator_mapping.go:36). It wraps FrameBaseOptions.Parse, which reads strict and timeout with coercing conversions and has no failing branch in current k6 — the wrap is defensive. Note that hidden/detached elements do NOT error here: the mapping deliberately resolves to null for ErrElementNotVisible/ErrElementNotAttachedToDOM to match Playwright.","triggerScenarios":"Exotic options values that sobek cannot traverse (Symbol, throwing getters); older k6 builds with stricter parsing. Ordinary wrong types like { timeout: '5000' } are coerced, not rejected.","commonSituations":"Assuming boundingBox() throws when an element is missing (it returns null — check the resolved value instead); passing option objects assembled from JSON with string timeouts on older k6.","solutions":["Pass a plain object { timeout: <number> } or nothing at all","Null-check the resolved value instead of relying on an error for hidden elements","Coerce dynamic timeout values with Number()","Upgrade k6 if a plain options object triggers this"],"exampleFix":"// before\nconst box = await locator.boundingBox({ timeout: __ENV.TIMEOUT });\n// after\nconst box = await locator.boundingBox({ timeout: Number(__ENV.TIMEOUT) });\nif (!box) throw new Error('element not visible');","handlingStrategy":"validation","validationCode":"const o = (opts == null) ? undefined : { ...(opts.timeout !== undefined && { timeout: Number(opts.timeout) }) };\nconst box = await locator.boundingBox(o);\nif (box === null) { /* element hidden or detached — handle, do not expect a throw */ }","typeGuard":"function isBoundingBoxOptions(o) {\n  return o == null || (typeof o === 'object' && !Array.isArray(o) &&\n    (o.timeout === undefined || typeof o.timeout === 'number'));\n}","tryCatchPattern":"try { const box = await locator.boundingBox(o); } catch (e) { if (!String(e.message).includes('parsing locator bounding box options')) throw e; }","preventionTips":["Null-check the resolved value; hidden elements resolve to null instead of throwing","Pass only { timeout } — boundingBox has no other meaningful options","Coerce external timeout values with Number()"],"tags":["k6","k6-browser","locator","bounding-box","options"],"backgroundTag":"options-validation-failed","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"}