{"record":{"id":"be17622075395a9b","repo":"GopeedLab/gopeed","slug":"missing-or-invalid-url","errorCode":null,"errorMessage":"missing or invalid \"url\"","messagePattern":"missing or invalid \"url\"","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/download/extension_runtime_webview.go","lineNumber":133,"sourceCode":"\treturn obj\n}\n\nfunc newJSWebViewPage(vm *goja.Runtime, page *enginewebview.PageHandle) *goja.Object {\n\tobj := vm.NewObject()\n\t_ = obj.Set(\"addInitScript\", func(call goja.FunctionCall) goja.Value {\n\t\tscript, err := requireStringArg(call, 0, \"script\")\n\t\tif err != nil {\n\t\t\tpanic(vm.ToValue(err))\n\t\t}\n\t\tif err := page.AddInitScript(script); err != nil {\n\t\t\tpanic(vm.ToValue(err))\n\t\t}\n\t\treturn goja.Undefined()\n\t})\n\t_ = obj.Set(\"goto\", func(call goja.FunctionCall) goja.Value {\n\t\turl, err := requireStringArg(call, 0, \"url\")\n\t\tif err != nil {\n\t\t\tpanic(vm.ToValue(err))\n\t\t}\n\t\tif err := page.Goto(\n\t\t\turl,\n\t\t\toptionalMap(call.Argument(1)),\n\t\t); err != nil {\n\t\t\tpanic(vm.ToValue(err))\n\t\t}\n\t\treturn goja.Undefined()\n\t})\n\t_ = obj.Set(\"execute\", func(call goja.FunctionCall) goja.Value {\n\t\texpression, err := enginewebview.NormalizeExecutableValue(call.Argument(0))\n\t\tif err != nil {\n\t\t\tpanic(vm.ToValue(err))\n\t\t}\n\t\tresult, err := page.Execute(expression, exportArgs(call.Arguments[1:])...)\n\t\tif err != nil {\n\t\t\tpanic(vm.ToValue(err))\n\t\t}","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/GopeedLab/gopeed/blob/7b7327ffb30816273a74b142cccc0bc10c5a4c67/pkg/download/extension_runtime_webview.go#L115-L151","documentation":"Argument-presence error from requireStringArg raised inside the webview page goto binding (extension_runtime_webview.go:130-134): the navigation was attempted without a usable URL. gopeed.runtime.webview page objects expose goto(url, options?), and the first argument must be present (non-nil, non-undefined, non-null) or the bridge panics before page.Goto is reached.","triggerScenarios":"Calling page.goto() with no arguments; passing a URL variable that is undefined because a string operation returned nothing; template strings that evaluate to undefined; navigating to a value read from a map with a missing key.","commonSituations":"Resolvers that build the target URL from response parsing (undefined on unexpected HTML); passing res.url when the resource object lacks the field; refactoring that shifted the options map into the first position.","solutions":["Pass the URL string as the first argument: page.goto(\"https://example.com/file\")","Compute and validate the URL before navigating (throw your own descriptive error when absent)","Default it when a fallback exists: page.goto(url ?? fallbackUrl)"],"exampleFix":"// before\nconst url = parsed.match(/href=\"([^\"]+)\"/)?.[1];\npage.goto(url);\n\n// after\nconst url = parsed.match(/href=\"([^\"]+)\"/)?.[1];\nif (!url) throw new Error(\"could not extract download URL\");\npage.goto(url, { timeout: 30000 });","handlingStrategy":"validation","validationCode":"if (typeof url !== \"string\" || url.length === 0) {\n  throw new Error(\"goto target url is required\");\n}\npage.goto(url);","typeGuard":"function isUrlString(v) {\n  return typeof v === \"string\" && /^https?:\\/\\//.test(v);\n}","tryCatchPattern":null,"preventionTips":["Extract URLs once, validate non-empty, then navigate","Throw descriptive errors at extraction time instead of forwarding undefined","Pass the options map as the second argument only"],"tags":["extension","webview","navigation","validation"],"backgroundTag":null,"analyzedSha":"7b7327ffb30816273a74b142cccc0bc10c5a4c67","analyzedAt":"2026-08-16T02:51:03.250Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}