{"record":{"id":"f78d69ee411013a4","repo":"grafana/k6","slug":"parsing-focus-options-w-f78d69","errorCode":null,"errorMessage":"parsing focus options: %w","messagePattern":"parsing focus options: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/browser/locator_mapping.go","lineNumber":213,"sourceCode":"\t\t\t\treturn nil, fmt.Errorf(\"parsing fill options: %w\", err)\n\t\t\t}\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\treturn nil, lo.Fill(value, copts) //nolint:wrapcheck\n\t\t\t}), nil\n\t\t},\n\t\t\"filter\": func(opts sobek.Value) mapping {\n\t\t\treturn mapLocator(vu, lo.Filter(&common.LocatorFilterOptions{\n\t\t\t\tLocatorOptions: parseLocatorOptions(rt, opts),\n\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}","sourceCodeStart":195,"sourceCodeEnd":231,"githubUrl":"https://github.com/grafana/k6/blob/8d06114777191d21ef885d05c5f8aa9e1ed838ae/internal/js/modules/k6/browser/browser/locator_mapping.go#L195-L231","documentation":"Thrown synchronously when the options argument to locator.focus() fails to parse. The mapping (locator_mapping.go:210-214) creates common.NewFrameBaseOptions(lo.Timeout()) and wraps any Parse failure as \"parsing focus options: %w\". FrameBaseOptions.Parse handles only strict and timeout via boolean/integer coercion and cannot fail on plain wrong-typed values, so the wrapped error means sobek itself raised reading the object — throwing getter, Proxy trap, or a value whose coercion throws.","triggerScenarios":"opts.timeout defined as a throwing getter; a Proxy around options with raising traps; a timeout whose toPrimitive raises during ToInteger.","commonSituations":"Focus wrappers in page objects that build options via accessors; debugging Proxies; passing the result of Object.create with getter prototypes.","solutions":["Call locator.focus() with no argument or a plain literal { timeout: ms }","Replace accessors with plain properties computed before the call","Do not hand Proxy-wrapped objects to browser module APIs","Catch synchronously with try/catch if inputs are untrusted"],"exampleFix":"// before\nawait locator.focus({ get timeout() { return getCfg('timeout'); } }); // getter throws on missing key\n\n// after\nconst timeout = getCfg('timeout');\nawait locator.focus({ timeout });","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  await locator.focus(opts);\n} catch (e) {\n  throw new Error(`focus failed (options must be plain { timeout, strict }): ${e}`);\n}","preventionTips":["Call focus() with no options when defaults suffice","Resolve timeout config before building the object","Keep options free of Proxy/accessor machinery"],"tags":["k6","browser","locator","focus","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"}