{"record":{"id":"67249b839ce37117","repo":"grafana/k6","slug":"parsing-getattribute-options-w","errorCode":null,"errorMessage":"parsing getAttribute options: %w","messagePattern":"parsing getAttribute options: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/browser/frame_mapping.go","lineNumber":126,"sourceCode":"\t\t\t\treturn nil, fmt.Errorf(\"parsing focus options: %w\", err)\n\t\t\t}\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\treturn nil, f.Focus(selector, popts) //nolint:wrapcheck\n\t\t\t}), nil\n\t\t},\n\t\t\"frameElement\": func() *sobek.Promise {\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\tfe, err := f.FrameElement()\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err //nolint:wrapcheck\n\t\t\t\t}\n\t\t\t\treturn mapElementHandle(vu, fe), nil\n\t\t\t})\n\t\t},\n\t\t\"getAttribute\": func(selector, name string, opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tpopts := common.NewFrameBaseOptions(f.Timeout())\n\t\t\tif err := parseFrameBaseOptions(popts, rt, opts); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing getAttribute options: %w\", err)\n\t\t\t}\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\ts, ok, err := f.GetAttribute(selector, name, popts)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err //nolint:wrapcheck\n\t\t\t\t}\n\t\t\t\tif !ok {\n\t\t\t\t\treturn nil, nil //nolint:nilnil\n\t\t\t\t}\n\t\t\t\treturn s, nil\n\t\t\t}), nil\n\t\t},\n\t\t\"getByAltText\": func(alt sobek.Value, opts sobek.Value) (*sobek.Object, error) {\n\t\t\tif k6common.IsNullish(alt) {\n\t\t\t\treturn nil, errors.New(\"missing required argument 'altText'\")\n\t\t\t}\n\t\t\tpalt, popts := parseGetByBaseOptions(vu.Context(), alt, false, opts)\n","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/grafana/k6/blob/8d06114777191d21ef885d05c5f8aa9e1ed838ae/internal/js/modules/k6/browser/browser/frame_mapping.go#L108-L144","documentation":"Thrown when the options argument to `frame.getAttribute(selector, name, opts)` fails to parse into FrameBaseOptions (keys: `strict`, `timeout` in ms). The error is raised synchronously before the promise is created, so it appears as a JS exception at the call site, not a rejected promise. In the current code the Parse loop is coercive and cannot fail; this wrapper is defensive.","triggerScenarios":"Calling `frame.getAttribute(sel, name, opts)` with a non-object or type-invalid opts under a k6 version whose Parse validates; today unknown keys are skipped and `strict`/`timeout` are coerced, so no runtime path produces this error.","commonSituations":"Copy-pasting Playwright snippets with unsupported keys; passing a string duration for timeout, which silently coerces to 0ms rather than erroring.","solutions":["Use only { strict, timeout } with numeric timeout in milliseconds","Check the wrapped cause in the error chain (fmt.Errorf %w) to see what the parser actually rejected","Call the method without opts or with undefined/null — both are accepted (IsNullish check)"],"exampleFix":"// before\nconst v = await frame.getAttribute('#a', 'href', { timeout: '5s' });\n\n// after\nconst v = await frame.getAttribute('#a', 'href', { timeout: 5000 });","handlingStrategy":"try-catch","validationCode":"const opts = { timeout: 5000, strict: false };\nconst extra = Object.keys(opts).filter(k => !['strict', 'timeout'].includes(k));\nif (extra.length) console.warn('getAttribute ignores unknown keys:', extra);","typeGuard":"function isFrameBaseOptions(o) {\n  return o == null || (\n    typeof o === 'object' &&\n    (o.timeout === undefined || typeof o.timeout === 'number') &&\n    (o.strict === undefined || typeof o.strict === 'boolean')\n  );\n}","tryCatchPattern":"try {\n  const href = await frame.getAttribute('#a', 'href', opts);\n} catch (e) {\n  if (String(e).includes('parsing getAttribute options')) { /* fix opts and retry */ } else { throw e; }\n}","preventionTips":["Use only strict/timeout keys on getAttribute","Numeric millisecond timeouts","getAttribute returns null for a missing attribute (ok flag) — do not confuse that with parse errors"],"tags":["k6","browser","frame","get-attribute","options","sobek"],"backgroundTag":"invalid-options-argument","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"}