{"record":{"id":"8037ed6d5dd517a7","repo":"iflytek/astron-agent","slug":"invalid-request-url-requset-url","errorCode":null,"errorMessage":"invalid request url:{requset_url}","messagePattern":"invalid request url:(.+?)","errorType":"exception","errorClass":"AssembleHeaderException","httpStatus":null,"severity":"error","filePath":"core/plugin/link/infra/tool_exector/http_auth.py","lineNumber":153,"sourceCode":"    \"\"\"\n    Parse a URL into its components.\n\n    Args:\n        requset_url (str): The URL to parse\n\n    Returns:\n        Url: A Url object containing host, path, and schema components\n\n    Raises:\n        AssembleHeaderException: If the URL format is invalid\n    \"\"\"\n    stidx = requset_url.index(\"://\")\n    host = requset_url[stidx + 3 :]\n    schema = requset_url[: stidx + 3]\n    try:\n        edidx = host.index(\"/\")\n    except ValueError:\n        raise AssembleHeaderException(\"invalid request url:\" + requset_url)\n    if edidx <= 0:\n        raise AssembleHeaderException(\"invalid request url:\" + requset_url)\n    path = host[edidx:]\n    host = host[:edidx]\n    u = Url(host, path, schema)\n    return u\n\n\n# build websocket auth request url\ndef assemble_ws_auth_url(\n    requset_url: str,\n    method: str,\n    auth_con_js: Dict[str, Any],\n    body: Optional[Dict[str, Any]] = None,\n) -> Tuple[str, Dict[str, str]]:\n    \"\"\"\n    Build WebSocket authentication request URL and headers.\n","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/plugin/link/infra/tool_exector/http_auth.py#L135-L171","documentation":"parse_url in the link plugin's WebSocket auth helper raises AssembleHeaderException when the URL has no path component at all: host.index(\"/\") throws ValueError because there is no '/' after the scheme. The function expects a full URL like 'wss://host/path'; a bare 'wss://host' cannot be split into host and path for HMAC header assembly.","triggerScenarios":"Passing assemble_ws_auth_url (via parse_url) a URL without any path, e.g. 'wss://apiserver.example.com' instead of 'wss://apiserver.example.com/v2/interact' — typically a misconfigured endpoint base URL stored in config or env.","commonSituations":"Configuring only the host of an upstream WebSocket API without its required route, copying an API domain from docs without the endpoint path, or stripping the path in URL-joining code.","solutions":["Append the required API path to the URL, e.g. 'wss://host/v2/interact' instead of 'wss://host'","Check the service's endpoint configuration/env var for the full URL including path","Catch AssembleHeaderException and log/validate the URL before calling assemble_ws_auth_url"],"exampleFix":"# before\nurl = \"wss://iat-api.xfyun.cn\"\nresult_url, headers = assemble_ws_auth_url(url, \"GET\", auth_config)  # raises\n# after\nurl = \"wss://iat-api.xfyun.cn/v2/iat\"\nresult_url, headers = assemble_ws_auth_url(url, \"GET\", auth_config)","handlingStrategy":"validation","validationCode":"from urllib.parse import urlparse\n\ndef assert_parseable_ws_url(url: str) -> None:\n    p = urlparse(url)\n    if p.scheme not in (\"ws\", \"wss\") or not p.hostname or not p.path:\n        raise ValueError(f\"URL must include scheme, host and path: {url}\")","typeGuard":null,"tryCatchPattern":"try:\n    result_url, headers = assemble_ws_auth_url(url, \"GET\", auth_config)\nexcept AssembleHeaderException as e:\n    logger.error(f\"bad endpoint url: {e.message}\")\n    raise ValueError(\"endpoint URL must include a path\") from e","preventionTips":["Always configure the full endpoint URL including its route path","Validate URLs with urlparse at config load time, not at request time","Copy endpoint paths from the vendor's API reference, not just the domain"],"tags":["url","websocket","authentication","config"],"backgroundTag":"invalid-url-format","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}