GopeedLab/gopeed · error
missing or invalid "selector"
Error message
missing or invalid "selector"
What it means
Argument-presence error from requireStringArg raised by the focus binding (extension_runtime_webview.go:154-158): page.focus(selector) was called with a nil/undefined/null selector. The bridge validates presence before page.Focus runs, and any missing selector aborts the extension script with this exception.
Source
Thrown at pkg/download/extension_runtime_webview.go:157
panic(vm.ToValue(err))
}
return goja.Undefined()
})
_ = obj.Set("execute", func(call goja.FunctionCall) goja.Value {
expression, err := enginewebview.NormalizeExecutableValue(call.Argument(0))
if err != nil {
panic(vm.ToValue(err))
}
result, err := page.Execute(expression, exportArgs(call.Arguments[1:])...)
if err != nil {
panic(vm.ToValue(err))
}
return vm.ToValue(result)
})
_ = obj.Set("focus", func(call goja.FunctionCall) goja.Value {
selector, err := requireStringArg(call, 0, "selector")
if err != nil {
panic(vm.ToValue(err))
}
if err := page.Focus(selector); err != nil {
panic(vm.ToValue(err))
}
return goja.Undefined()
})
_ = obj.Set("click", func(call goja.FunctionCall) goja.Value {
selector, err := requireStringArg(call, 0, "selector")
if err != nil {
panic(vm.ToValue(err))
}
if err := page.Click(selector, optionalMap(call.Argument(1))); err != nil {
panic(vm.ToValue(err))
}
return goja.Undefined()
})
_ = obj.Set("type", func(call goja.FunctionCall) goja.Value {
selector, err := requireStringArg(call, 0, "selector")View on GitHub (pinned to 7b7327ffb3)
Solutions
- Pass a concrete CSS selector: page.focus("#username")
- Guard dynamic selectors with a fallback or your own error before calling focus
- Verify the selector table has an entry for the current site
Example fix
// before
const sel = selectors[host]; // undefined for unknown host
page.focus(sel);
// after
const sel = selectors[host];
if (!sel) throw new Error(`no focus selector for host ${host}`);
page.focus(sel); Defensive patterns
Strategy: validation
Validate before calling
if (!sel) throw new Error("focus selector is required");
page.focus(sel); Type guard
function isSelector(v) {
return typeof v === "string" && v.trim().length > 0;
} Prevention
- Keep per-site selector maps exhaustive and validate them at startup
- Skip focus when the target is optional instead of calling with undefined
- Reuse one shared selector-constant module across the extension
When it happens
Trigger: Calling page.focus() with no arguments; passing a selector variable that is undefined because a selector-lookup table had no entry; forwarding an optional parameter that the caller omitted.
Common situations: Site-specific selectors stored per-domain where one domain lacks an entry; refactors renaming the selector variable at the call site only; selector arrays iterated with a sparse index yielding undefined.
Related errors
- missing or invalid "%s"
- missing or invalid "url"
- execute expects a string or function
- missing or invalid "text"
- invalid resource file name
AI-assisted analysis of GopeedLab/gopeed@7b7327ffb3 (2026-08-16).
Data as JSON: /api/errors/76cb70397fa917eb.
Report an issue: GitHub.