{"record":{"id":"3dca785591539793","repo":"GopeedLab/gopeed","slug":"missing-or-invalid-s","errorCode":null,"errorMessage":"missing or invalid \"%s\"","messagePattern":"missing or invalid \"(.+?)\"","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/download/extension_runtime_webview.go","lineNumber":286,"sourceCode":"\t}\n\treturn nil\n}\n\nfunc exportArgs(values []goja.Value) []any {\n\tif len(values) == 0 {\n\t\treturn nil\n\t}\n\targs := make([]any, 0, len(values))\n\tfor _, value := range values {\n\t\targs = append(args, value.Export())\n\t}\n\treturn args\n}\n\nfunc requireStringArg(call goja.FunctionCall, index int, name string) (string, error) {\n\tvalue := call.Argument(index)\n\tif value == nil || goja.IsUndefined(value) || goja.IsNull(value) {\n\t\treturn \"\", fmt.Errorf(`missing or invalid \"%s\"`, name)\n\t}\n\treturn value.String(), nil\n}\n","sourceCodeStart":268,"sourceCodeEnd":290,"githubUrl":"https://github.com/GopeedLab/gopeed/blob/7b7327ffb30816273a74b142cccc0bc10c5a4c67/pkg/download/extension_runtime_webview.go#L268-L290","documentation":"Generic argument-presence error from requireStringArg (extension_runtime_webview.go:283-289), the helper behind every webview page method that needs a string. It fires only when the argument at the named position is nil, undefined or null; any other value (number, object) is silently coerced via value.String(). The %s placeholder names the offending argument: \"script\", \"url\", \"selector\" or \"text\".","triggerScenarios":"Calling any string-taking webview page method with the required argument omitted or explicitly undefined/null: addInitScript(), goto(url), focus(selector), click(selector), type(selector, text), waitForSelector(selector). Also triggered by passing undefined variables (selector computed from a query that returned nothing).","commonSituations":"Selectors built dynamically from page content that is absent (undefined); optional-chained expressions leaking undefined into arguments; refactors that reorder parameters; calling type() without the text argument.","solutions":["Supply the named argument with a concrete string value","Default dynamic values: page.click(selector ?? \"#download\")","Log the selector/URL before the call when it is computed at runtime"],"exampleFix":"// before\nconst selector = links.find((l) => l.rel === \"next\")?.href;\npage.waitForSelector(selector);\n\n// after\nconst selector = links.find((l) => l.rel === \"next\")?.href;\nif (!selector) throw new Error(\"next link not found\");\npage.waitForSelector(selector);","handlingStrategy":"validation","validationCode":"function requireStr(value, name) {\n  if (value === undefined || value === null) {\n    throw new TypeError(`missing or invalid \"${name}\"`);\n  }\n  return String(value);\n}","typeGuard":"function isNonEmptyString(v) {\n  return typeof v === \"string\" && v.length > 0;\n}","tryCatchPattern":null,"preventionTips":["Default dynamic arguments: page.click(selector ?? \"#fallback\")","Fail fast with your own descriptive error when a computed selector/url is absent","Remember the bridge coerces numbers/objects silently; validate string-ness yourself"],"tags":["extension","webview","javascript","validation"],"backgroundTag":null,"analyzedSha":"7b7327ffb30816273a74b142cccc0bc10c5a4c67","analyzedAt":"2026-08-16T02:51:03.250Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}