{"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":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/browser/locator_mapping.go","lineNumber":391,"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 := common.NewFrameTypeOptions(lo.Timeout())\n\t\t\tif err := copts.Parse(vu.Context(), opts); 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 := common.NewFrameTypeOptions(lo.Timeout())\n\t\t\tif err := copts.Parse(vu.Context(), opts); 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 := common.NewFrameHoverOptions(lo.Timeout())\n\t\t\tif err := copts.Parse(vu.Context(), opts); 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 := common.NewFrameTapOptions(lo.DefaultTimeout())\n\t\t\tif err := copts.Parse(vu.Context(), opts); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing locator tap options: %w\", err)","sourceCodeStart":373,"sourceCodeEnd":409,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/browser/locator_mapping.go#L373-L409","documentation":"Thrown when locator.type(text, opts) fails to parse options into FrameTypeOptions (delay number in ms, timeout number in ms; strict). The mapping wraps the cause as 'parsing type options: %w'. locator.type is the deprecated predecessor of pressSequentially; the parser is lenient, so this error means the opts slot was not a valid plain options object.","triggerScenarios":"Calling locator.type('hello', '50ms') or type('hello', 50) — scalar in the opts slot; wrong-typed delay/timeout on strict k6 builds; passing the text positionally into options.","commonSituations":"Older example scripts and blog posts using type(); migrating them while carrying string durations; mixing fill() and type() call signatures.","solutions":["Pass a plain object: type('hello', { delay: 50 }) or omit the second argument","Replace type() with pressSequentially(), its supported replacement, and verify the options shape there","Use numeric milliseconds for delay and timeout","Upgrade k6 so deprecated method warnings guide the migration"],"exampleFix":"// before\nawait page.locator('input').type('k6', '50ms');\n\n// after\nawait page.locator('input').pressSequentially('k6', { delay: 50 });","handlingStrategy":"validation","validationCode":"function assertTypeOpts(method, opts) {\n  if (opts === null || opts === undefined) return;\n  if (typeof opts !== 'object' || Array.isArray(opts)) {\n    throw new TypeError(`${method} options must be a plain object`);\n  }\n  for (const k of ['delay', 'timeout']) {\n    if (k in opts && typeof opts[k] !== 'number') {\n      throw new TypeError(`${method} ${k} must be a number (ms)`);\n    }\n  }\n}\nassertTypeOpts('type', opts);","typeGuard":"function isTypeOptions(v) {\n  if (v === null || v === undefined) return true;\n  if (typeof v !== 'object' || Array.isArray(v)) return false;\n  return (v.delay === undefined || typeof v.delay === 'number') &&\n         (v.timeout === undefined || typeof v.timeout === 'number');\n}","tryCatchPattern":"try {\n  await locator.type(text, opts);\n} catch (e) {\n  if (/parsing type options/.test(String(e.message))) {\n    throw new Error(`Bad type options: ${JSON.stringify(opts)}`);\n  }\n  throw e;\n}","preventionTips":["Replace deprecated type() with pressSequentially() during routine maintenance","Keep delay/timeout numeric in milliseconds","Omit options when no per-keystroke delay is needed"],"tags":["k6","browser","locator","options","type","deprecated"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}