GopeedLab/gopeed · error

missing or invalid "%s"

Error message

missing or invalid "%s"

What it means

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".

Source

Thrown at pkg/download/extension_runtime_webview.go:286

	}
	return nil
}

func exportArgs(values []goja.Value) []any {
	if len(values) == 0 {
		return nil
	}
	args := make([]any, 0, len(values))
	for _, value := range values {
		args = append(args, value.Export())
	}
	return args
}

func requireStringArg(call goja.FunctionCall, index int, name string) (string, error) {
	value := call.Argument(index)
	if value == nil || goja.IsUndefined(value) || goja.IsNull(value) {
		return "", fmt.Errorf(`missing or invalid "%s"`, name)
	}
	return value.String(), nil
}

View on GitHub (pinned to 7b7327ffb3)

Solutions

  1. Supply the named argument with a concrete string value
  2. Default dynamic values: page.click(selector ?? "#download")
  3. Log the selector/URL before the call when it is computed at runtime

Example fix

// before
const selector = links.find((l) => l.rel === "next")?.href;
page.waitForSelector(selector);

// after
const selector = links.find((l) => l.rel === "next")?.href;
if (!selector) throw new Error("next link not found");
page.waitForSelector(selector);
Defensive patterns

Strategy: validation

Validate before calling

function requireStr(value, name) {
  if (value === undefined || value === null) {
    throw new TypeError(`missing or invalid "${name}"`);
  }
  return String(value);
}

Type guard

function isNonEmptyString(v) {
  return typeof v === "string" && v.length > 0;
}

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of GopeedLab/gopeed@7b7327ffb3 (2026-08-16). Data as JSON: /api/errors/3dca785591539793. Report an issue: GitHub.