{"record":{"id":"3cd495a8c458907f","repo":"grafana/k6","slug":"parsing-setcontent-options-w-3cd495","errorCode":null,"errorMessage":"parsing setContent options: %w","messagePattern":"parsing setContent options: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/frame_options.go","lineNumber":537,"sourceCode":"\t\tTimeout:   defaultTimeout,\n\t\tWaitUntil: LifecycleEventLoad,\n\t}\n}\n\n// Parse parses the frame setContent options.\nfunc (o *FrameSetContentOptions) Parse(ctx context.Context, opts sobek.Value) error {\n\trt := k6ext.Runtime(ctx)\n\n\tif !common.IsNullish(opts) {\n\t\topts := opts.ToObject(rt)\n\t\tfor _, k := range opts.Keys() {\n\t\t\tswitch k {\n\t\t\tcase \"timeout\":\n\t\t\t\to.Timeout = time.Duration(opts.Get(k).ToInteger()) * time.Millisecond\n\t\t\tcase \"waitUntil\":\n\t\t\t\tlifeCycle := opts.Get(k).String()\n\t\t\t\tif err := o.WaitUntil.UnmarshalText([]byte(lifeCycle)); err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"parsing setContent options: %w\", err)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}\n\n// NewFrameSetInputFilesOptions creates a new FrameSetInputFilesOptions.\nfunc NewFrameSetInputFilesOptions(defaultTimeout time.Duration) *FrameSetInputFilesOptions {\n\treturn &FrameSetInputFilesOptions{\n\t\tElementHandleSetInputFilesOptions: *NewElementHandleSetInputFilesOptions(defaultTimeout),\n\t\tStrict:                            false,\n\t}\n}\n\n// Parse parses FrameSetInputFilesOptions from sobek.Value.\nfunc (o *FrameSetInputFilesOptions) Parse(ctx context.Context, opts sobek.Value) error {","sourceCodeStart":519,"sourceCodeEnd":555,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/common/frame_options.go#L519-L555","documentation":"FrameSetContentOptions.Parse (frame_options.go:537) validates the `waitUntil` option of frame.setContent()/page.setContent() through LifecycleEvent.UnmarshalText. Acceptable values are only \"load\", \"domcontentloaded\" and \"networkidle\"; anything else fails and is wrapped with this message before any content is set. Like goto, this is local validation, not a Chromium error.","triggerScenarios":"page.setContent(html, { waitUntil: ... }) with unsupported or misspelled values such as 'load-complete', 'NetworkIdle', 'domcontent-loaded', or 'idle'. Only \"timeout\" and \"waitUntil\" keys are honored by this parser.","commonSituations":"Porting setContent calls from Playwright where extra waitUntil values exist, or generating options dynamically with unvalidated strings from config files/environment variables.","solutions":["Change the waitUntil value to \"load\", \"domcontentloaded\" or \"networkidle\"","Centralize lifecycle constants in your script so config-driven values cannot drift from the supported set","Check for typos and casing — matching is exact and lowercase"],"exampleFix":"// before\npage.setContent('<h1>hi</h1>', { waitUntil: 'NetworkIdle' });\n\n// after\npage.setContent('<h1>hi</h1>', { waitUntil: 'networkidle' });","handlingStrategy":"validation","validationCode":"const WAIT_UNTIL = ['load', 'domcontentloaded', 'networkidle'];\nif (opts && opts.waitUntil !== undefined && !WAIT_UNTIL.includes(opts.waitUntil)) {\n  throw new Error(`invalid waitUntil: ${opts.waitUntil}`);\n}\npage.setContent(html, opts);","typeGuard":"function isWaitUntil(v: unknown): v is 'load' | 'domcontentloaded' | 'networkidle' {\n  return typeof v === 'string' && ['load', 'domcontentloaded', 'networkidle'].includes(v);\n}","tryCatchPattern":null,"preventionTips":["Only timeout and waitUntil are parsed for setContent — do not pass other keys expecting effect","Validate config-driven option strings before the run, not during"],"tags":["browser","options","waituntil","setcontent","validation"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}