{"record":{"id":"47a582e59ffd3979","repo":"grafana/k6","slug":"parsing-fill-options-w-47a582","errorCode":null,"errorMessage":"parsing fill options: %w","messagePattern":"parsing fill options: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/browser/locator_mapping.go","lineNumber":195,"sourceCode":"\t\t\t}\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\treturn lo.IsInViewport(copts) //nolint:wrapcheck\n\t\t\t}), nil\n\t\t},\n\t\t\"isVisible\": func() *sobek.Promise {\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\treturn lo.IsVisible() //nolint:wrapcheck\n\t\t\t})\n\t\t},\n\t\t\"isHidden\": func() *sobek.Promise {\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\treturn lo.IsHidden() //nolint:wrapcheck\n\t\t\t})\n\t\t},\n\t\t\"fill\": func(value string, 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 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)","sourceCodeStart":177,"sourceCodeEnd":213,"githubUrl":"https://github.com/grafana/k6/blob/8d06114777191d21ef885d05c5f8aa9e1ed838ae/internal/js/modules/k6/browser/browser/locator_mapping.go#L177-L213","documentation":"Thrown synchronously when the options argument to locator.fill() fails to parse. The mapping (locator_mapping.go:192-196) builds common.FrameFillOptions and wraps Parse failures as \"parsing fill options: %w\". Parse delegates to ElementHandleBaseOptions.Parse, which reads force, noWaitAfter and timeout with coercing accessors and returns nil on ordinary values — so the wrapped error indicates sobek raised while enumerating or reading the options object (throwing getter, Proxy trap, or throwing implicit conversion).","triggerScenarios":"An options getter for force/noWaitAfter/timeout that raises; Proxy-wrapped options with throwing get/ownKeys traps; a timeout object whose toPrimitive/valueOf throws during ToInteger.","commonSituations":"Page objects exposing lazily-validated config getters; logging Proxies applied to all call arguments; passing a class instance with accessors instead of a literal.","solutions":["Pass a plain literal: locator.fill('text', { timeout: 5000, force: true })","Precompute dynamic values; avoid getters/Proxies on options","Keep keys to the documented set (force, noWaitAfter, timeout, strict) as plain data","try/catch the call and report which option broke"],"exampleFix":"// before\nawait locator.fill(userInput, instrumentedOpts); // Proxy throws in get trap\n\n// after\nconst { timeout, force } = instrumentedOpts; // destructure first\nawait locator.fill(userInput, { timeout, force });","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isPlainFillOptions(o) {\n  return o == null || (typeof o === 'object' &&\n    (o.timeout === undefined || typeof o.timeout === 'number') &&\n    (o.force === undefined || typeof o.force === 'boolean') &&\n    (o.noWaitAfter === undefined || typeof o.noWaitAfter === 'boolean') &&\n    (o.strict === undefined || typeof o.strict === 'boolean'));\n}","tryCatchPattern":"try {\n  await locator.fill(value, opts);\n} catch (e) {\n  throw new Error(`fill failed (ensure options are plain force/noWaitAfter/timeout/strict values): ${e}`);\n}","preventionTips":["Use plain literals: locator.fill('x', { timeout: 5000, force: true })","Destructure proxied/instrumented objects into plain values first","Do not define getters on fill options"],"tags":["k6","browser","locator","fill","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"}