{"record":{"id":"efc685eac0eb3de1","repo":"grafana/k6","slug":"parsing-text-content-options-w-efc685","errorCode":null,"errorMessage":"parsing text content options: %w","messagePattern":"parsing text content options: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/browser/locator_mapping.go","lineNumber":334,"sourceCode":"\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing inner text options: %w\", err)\n\t\t\t}\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\treturn lo.InnerText(copts) //nolint:wrapcheck\n\t\t\t}), nil\n\t\t},\n\t\t\"last\": func() *sobek.Object {\n\t\t\tml := mapLocator(vu, lo.Last())\n\t\t\treturn rt.ToValue(ml).ToObject(rt)\n\t\t},\n\t\t\"nth\": func(nth int) *sobek.Object {\n\t\t\tml := mapLocator(vu, lo.Nth(nth))\n\t\t\treturn rt.ToValue(ml).ToObject(rt)\n\t\t},\n\t\t\"textContent\": func(opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tcopts, err := parseFrameTextContentOptions(rt, opts, lo.Timeout())\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing text content options: %w\", err)\n\t\t\t}\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\ts, ok, err := lo.TextContent(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\"inputValue\": func(opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tcopts, err := parseFrameInputValueOptions(rt, opts, lo.Timeout())\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing input value options: %w\", err)\n\t\t\t}\n\t\t\treturn promise(vu, func() (any, error) {","sourceCodeStart":316,"sourceCodeEnd":352,"githubUrl":"https://github.com/grafana/k6/blob/8d06114777191d21ef885d05c5f8aa9e1ed838ae/internal/js/modules/k6/browser/browser/locator_mapping.go#L316-L352","documentation":"Thrown synchronously when the options argument to locator.textContent() fails to parse. The mapping (locator_mapping.go:331-335) creates common.FrameTextContentOptions (FrameBaseOptions) and wraps any Parse failure as \"parsing text content options: %w\". FrameBaseOptions.Parse handles only strict/timeout via coercing accessors and never fails on ordinary mistyped values, so the wrapped error arises from sobek raising during property access on the options object (throwing getter, Proxy trap, or throwing implicit conversion).","triggerScenarios":"A throwing getter defined for timeout or strict; a Proxy around options whose get/ownKeys traps raise; a timeout value whose valueOf/Symbol.toPrimitive throws during ToInteger.","commonSituations":"Content-assertion helpers with accessor-based option objects; instrumentation Proxies; passing non-plain objects where a literal is expected.","solutions":["Pass a plain literal { timeout: ms } or call locator.textContent() with no options","Materialize computed values before the call","Strip Proxy/accessor wrappers from options","Catch the synchronous throw with try/catch and log which option failed"],"exampleFix":"// before\nconst opts = {}; Object.defineProperty(opts, 'timeout', { get: () => cfg.get('t') }); // throws when unset\nawait locator.textContent(opts);\n\n// after\nawait locator.textContent({ timeout: cfg.get('t') ?? 3000 });","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 text = await locator.textContent(opts);\n} catch (e) {\n  throw new Error(`textContent failed (options must be plain { timeout, strict }): ${e}`);\n}","preventionTips":["Use plain literals; avoid getters","Resolve config values before the call","Prefer no options unless overriding timeout"],"tags":["k6","browser","locator","textcontent","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"}