{"record":{"id":"3a902cd02c139ddd","repo":"grafana/k6","slug":"missing-required-argument-url","errorCode":null,"errorMessage":"missing required argument 'url'","messagePattern":"missing required argument 'url'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/browser/page_mapping.go","lineNumber":969,"sourceCode":"\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"page.route('%s'): %w\", path, err)\n\t\t\t}\n\t\t\treturn nil\n\t\t}\n\n\t\treturn promise(vu, func() (any, error) {\n\t\t\treturn nil, p.Route(ppath, route, newRegExMatcher(ctx, vu, tq))\n\t\t}), nil\n\t}\n}\n\nfunc mapWaitForURL(vu moduleVU, target interface {\n\tTimeout() time.Duration\n\tWaitForURL(urlPattern string, opts *common.FrameWaitForURLOptions, rm common.RegExMatcher) error\n}, url sobek.Value, opts sobek.Value,\n) (*sobek.Promise, error) {\n\tif k6common.IsNullish(url) {\n\t\treturn nil, errors.New(\"missing required argument 'url'\")\n\t}\n\tpopts := common.NewFrameWaitForURLOptions(target.Timeout())\n\tif err := popts.Parse(vu.Context(), opts); err != nil {\n\t\treturn nil, fmt.Errorf(\"parsing waitForURL options: %w\", err)\n\t}\n\n\tpurl := parseStringOrRegex(url, false)\n\ttq, ctx, stop := newTaskQueue(vu)\n\n\treturn promise(vu, func() (result any, reason error) {\n\t\tdefer stop()\n\t\treturn nil, target.WaitForURL(purl, popts, newRegExMatcher(ctx, vu, tq))\n\t}), nil\n}\n\nfunc mapWaitForNavigation(vu moduleVU, target interface {\n\tTimeout() time.Duration\n\tWaitForNavigation(*common.FrameWaitForNavigationOptions, common.RegExMatcher) (*common.Response, error)","sourceCodeStart":951,"sourceCodeEnd":987,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/js/modules/k6/browser/browser/page_mapping.go#L951-L987","documentation":"Thrown by mapWaitForURL (internal/js/modules/k6/browser/browser/page_mapping.go:969), the shared implementation of page.waitForURL() and frame.waitForURL(). The url argument is mandatory and must be a glob-style string or a RegExp (parsed by parseStringOrRegex); the nullish guard fails the call before the wait promise is even created, because there is nothing to match the navigation URL against.","triggerScenarios":"Calling page.waitForURL() with zero arguments; passing undefined/null explicitly; passing a URL pattern built from a template variable that is undefined (missing env var, absent config key), or passing options as the first argument by mistake.","commonSituations":"Waiting on a redirect target read from __ENV or options that was never set; ports of Playwright's page.waitForURL where the pattern got dropped; passing an options object first ({ timeout: 5000 }) instead of the URL.","solutions":["Pass a glob string or RegExp: await page.waitForURL('**/dashboard'), await page.waitForURL(/\\/dashboard\\?session=.+/)","Default dynamic patterns: const target = __ENV.TARGET_URL ?? '**/dashboard'","If you only need a timeout, pass it as the second argument: page.waitForURL('**/dashboard', { timeout: 5000 })","Log the pattern before the call to find where it becomes undefined"],"exampleFix":"// before\nawait page.waitForURL(__ENV.EXPECTED_PATH); // env var not set -> undefined\n\n// after\nawait page.waitForURL(__ENV.EXPECTED_PATH ?? '**/dashboard', { timeout: 10_000 });","handlingStrategy":"validation","validationCode":"const target = __ENV.EXPECTED_PATH ?? '**/dashboard';\nif (target === undefined || target === null) throw new Error('url is required');\nawait page.waitForURL(target, { timeout: 10_000 });","typeGuard":"function isGlobOrRegex(v) {\n  return (typeof v === 'string' && v.length > 0) || v instanceof RegExp;\n}\n// usage: if (!isGlobOrRegex(target)) throw new Error('waitForURL needs a glob string or RegExp');","tryCatchPattern":"try {\n  await page.waitForURL(target);\n} catch (e) {\n  if (/missing required argument 'url'/.test(e.message)) throw new Error('waitForURL called without a URL pattern');\n  throw e;\n}","preventionTips":["Always pass a glob string or RegExp as the first argument; options go second","Default env-driven URL patterns with ?? instead of trusting __ENV","Set a realistic timeout via the second argument rather than omitting the first","Use editor typings so the missing first argument is flagged"],"tags":["browser","navigation","wait","argument-validation","api-misuse"],"backgroundTag":"missing-required-argument","analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}