{"record":{"id":"d72b2051a22f2057","repo":"grafana/k6","slug":"parsing-type-options-w-d72b20","errorCode":null,"errorMessage":"parsing type options: %w","messagePattern":"parsing type options: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/browser/locator_mapping.go","lineNumber":392,"sourceCode":"\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\treturn nil, lo.Press(key, copts) //nolint:wrapcheck\n\t\t\t}), nil\n\t\t},\n\n\t\t\"pressSequentially\": func(text string, opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tcopts, err := parseFrameTypeOptions(rt, opts, lo.Timeout())\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing locator press sequentially options: %w\", err)\n\t\t\t}\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\treturn nil, lo.PressSequentially(text, copts) //nolint:wrapcheck\n\t\t\t}), nil\n\t\t},\n\n\t\t\"type\": func(text string, opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tcopts, err := parseFrameTypeOptions(rt, opts, lo.Timeout())\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing type options: %w\", err)\n\t\t\t}\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\treturn nil, lo.Type(text, copts) //nolint:wrapcheck\n\t\t\t}), nil\n\t\t},\n\t\t\"hover\": func(opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tcopts, err := parseFrameHoverOptions(rt, opts, lo.Timeout())\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing hover options: %w\", err)\n\t\t\t}\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\treturn nil, lo.Hover(copts) //nolint:wrapcheck\n\t\t\t}), nil\n\t\t},\n\t\t\"tap\": func(opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tcopts, err := parseFrameTapOptions(rt, opts, lo.DefaultTimeout())\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing locator tap options: %w\", err)","sourceCodeStart":374,"sourceCodeEnd":410,"githubUrl":"https://github.com/grafana/k6/blob/8d06114777191d21ef885d05c5f8aa9e1ed838ae/internal/js/modules/k6/browser/browser/locator_mapping.go#L374-L410","documentation":"Thrown synchronously when the options argument to locator.type(text, opts) fails to parse. The mapping (locator_mapping.go:388-392) builds common.FrameTypeOptions (seeding ElementHandleTypeOptions with the locator timeout) and wraps Parse failures as \"parsing type options: %w\". Parse reads delay, noWaitAfter and timeout with coercing accessors that do not fail on plain mistyped values, so an actual occurrence means sobek raised while reading the object — a throwing getter, a Proxy trap, or a value whose coercion to number throws.","triggerScenarios":"Options with a raising getter on delay/noWaitAfter/timeout; Proxy-wrapped options whose traps throw; a timeout/delay with a throwing toPrimitive/valueOf.","commonSituations":"Typing helpers with lazily-resolved delay config; debugging Proxies over all arguments; Playwright-to-k6 ports where option objects were subclassed with accessors.","solutions":["Pass a plain literal: locator.type('user@example.com', { delay: 20 })","Materialize computed values before the call","Do not wrap options in Proxies or define getters on them","Catch synchronously with try/catch if options come from untrusted sources"],"exampleFix":"// before\nawait locator.type(creds.user, { get delay() { return getTypingDelay(); } }); // throws when config missing\n\n// after\nconst delay = getTypingDelay() ?? 0;\nawait locator.type(creds.user, { delay });","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isPlainTypeOptions(o) {\n  return o == null || (typeof o === 'object' &&\n    (o.delay === undefined || Number.isFinite(o.delay)) &&\n    (o.noWaitAfter === undefined || typeof o.noWaitAfter === 'boolean') &&\n    (o.timeout === undefined || Number.isFinite(o.timeout)));\n}","tryCatchPattern":"try {\n  await locator.type(text, opts);\n} catch (e) {\n  throw new Error(`type failed (options must be plain delay/noWaitAfter/timeout values): ${e}`);\n}","preventionTips":["Pass delay/timeout as plain numbers","Precompute dynamic option values","Keep options object a literal with documented keys only"],"tags":["k6","browser","locator","type","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"}