sansan0/TrendRadar · error · InvalidParameterError

INVALID_PARAMETER

INVALID_PARAMETER

Error message

无效的 URL: {url}

What it means

InvalidParameterError from read_article in article_reader.py: the URL must be a non-empty string starting with http:// or https:// before any network call is made (the Jina Reader proxy prefix is prepended afterward). This is a pure input-format check, raised before the throttle and the HTTP request. Code INVALID_PARAMETER.

Source

Thrown at mcp_server/tools/article_reader.py:75

    def read_article(
        self,
        url: str,
        timeout: int = DEFAULT_TIMEOUT
    ) -> Dict:
        """
        读取单篇文章内容(Markdown 格式)

        Args:
            url: 文章链接
            timeout: 请求超时时间(秒),默认 30

        Returns:
            文章内容字典
        """
        try:
            if not url or not url.startswith(("http://", "https://")):
                raise InvalidParameterError(
                    f"无效的 URL: {url}",
                    suggestion="URL 必须以 http:// 或 https:// 开头"
                )

            self._throttle()

            response = requests.get(
                f"{JINA_READER_BASE}/{url}",
                headers=self._build_headers(),
                timeout=timeout
            )

            if response.status_code == 200:
                return {
                    "success": True,
                    "data": {
                        "url": url,
                        "content": response.text,

View on GitHub (pinned to 8ee26026ba)

Solutions

  1. Ensure the URL starts with http:// or https:// (add https:// to bare domains).
  2. Strip whitespace and validate format before calling.
  3. Check that you passed the URL field, not the title field, of a news item.

Example fix

# before
reader.read_article(url="www.example.com/post")
# after
url = url.strip()
if not url.startswith(("http://", "https://")):
    url = "https://" + url
reader.read_article(url=url)
Defensive patterns

Strategy: validation

Validate before calling

def normalize_url(u: str) -> str | None:
    if not isinstance(u, str):
        return None
    u = u.strip()
    if not u.startswith(("http://", "https://")):
        u = "https://" + u
    return u if u.startswith(("http://", "https://")) else None

url = normalize_url(url)
if url is None:
    raise ValueError("not a usable URL")

Type guard

def is_http_url(v) -> TypeGuard[str]:
    return isinstance(v, str) and v.startswith(("http://", "https://"))

Prevention

When it happens

Trigger: Passing None, an empty string, 'ftp://…', 'www.example.com' (no scheme), or a relative path; URLs extracted from markdown where the scheme got stripped; whitespace-prefixed URLs still fail if they don't start with the scheme.

Common situations: Feeding crawler output fields that contain bare domains; LLM tool callers passing the article title instead of a URL; copy-paste losing the scheme; data source returning mobileUrl without protocol.

Related errors


AI-assisted analysis of sansan0/TrendRadar@8ee26026ba (2026-08-15). Data as JSON: /api/errors/9845e74fddf9894c. Report an issue: GitHub.