{"record":{"id":"059b216195916d8f","repo":"grafana/k6","slug":"parsing-get-attribute-options-w","errorCode":null,"errorMessage":"parsing get attribute options: %w","messagePattern":"parsing get attribute options: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/browser/locator_mapping.go","lineNumber":222,"sourceCode":"\t\t\t}))\n\t\t},\n\t\t\"first\": func() *sobek.Object {\n\t\t\tml := mapLocator(vu, lo.First())\n\t\t\treturn rt.ToValue(ml).ToObject(rt)\n\t\t},\n\t\t\"focus\": func(opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tcopts := common.NewFrameBaseOptions(lo.Timeout())\n\t\t\tif err := parseFrameBaseOptions(copts, rt, opts); err != nil {\n\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, lo.Focus(copts) //nolint:wrapcheck\n\t\t\t}), nil\n\t\t},\n\t\t\"getAttribute\": func(name string, opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tcopts := common.NewFrameBaseOptions(lo.Timeout())\n\t\t\tif err := parseFrameBaseOptions(copts, rt, opts); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing get attribute options: %w\", err)\n\t\t\t}\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\ts, ok, err := lo.GetAttribute(name, copts)\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\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":204,"sourceCodeEnd":240,"githubUrl":"https://github.com/grafana/k6/blob/8d06114777191d21ef885d05c5f8aa9e1ed838ae/internal/js/modules/k6/browser/browser/locator_mapping.go#L204-L240","documentation":"Thrown synchronously when the options argument to locator.getAttribute(name, opts) fails to parse. The mapping (locator_mapping.go:218-222) builds FrameBaseOptions with the locator timeout and wraps Parse errors as \"parsing get attribute options: %w\". Since FrameBaseOptions.Parse only reads strict/timeout with coercing accessors that tolerate ordinary type mistakes, an actual failure comes from sobek raising during ToObject/Keys/Get — i.e. a throwing getter, a Proxy trap, or a throwing valueOf on the values.","triggerScenarios":"Options object with a getter for timeout/strict that raises; Proxy options whose get or ownKeys traps throw; a timeout value with a throwing toPrimitive during integer coercion.","commonSituations":"Attribute-fetch helpers that accept config objects with validation getters; argument tracing Proxies; passing exotic objects where a plain literal is expected.","solutions":["Pass a plain literal: locator.getAttribute('href', { timeout: 3000 }) or omit options","Materialize dynamic values before the call","Avoid Proxies/accessors on options handed to the browser module","Wrap in try/catch to fail the iteration cleanly"],"exampleFix":"// before\nawait locator.getAttribute('href', optsProxy); // get trap throws\n\n// after\nconst opts = { timeout: optsProxy.timeout };\nawait locator.getAttribute('href', opts);","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isPlainBaseOptions(o) {\n  return o == null || (typeof o === 'object' &&\n    (o.timeout === undefined || typeof o.timeout === 'number') &&\n    (o.strict === undefined || typeof o.strict === 'boolean'));\n}","tryCatchPattern":"try {\n  const href = await locator.getAttribute('href', opts);\n} catch (e) {\n  throw new Error(`getAttribute failed (check the options object, not the attribute name): ${e}`);\n}","preventionTips":["Pass { timeout: ms } as a plain literal or omit options","Validate config objects before handing them to browser APIs","Avoid tracing Proxies on arguments"],"tags":["k6","browser","locator","getattribute","options"],"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"}