{"record":{"id":"f8b8aad9b5609e64","repo":"iflytek/astron-agent","slug":"invalid-task-query-url-task-query-url","errorCode":null,"errorMessage":"Invalid task query URL: {task_query_url}","messagePattern":"Invalid task query URL: (.+?)","errorType":"exception","errorClass":"InvalidConfigException","httpStatus":null,"severity":"error","filePath":"core/plugin/rpa/infra/xiaowu/tasks.py","lineNumber":104,"sourceCode":"            logger.error(f\"Task creation failed: {e}\")\n            raise HTTPException(\n                status_code=500, detail=f\"Task creation failed: {e}\"\n            ) from e\n\n\n# Query task status\nasync def query_task_status(\n    access_token: str, task_id: str\n) -> Tuple[int, str, dict] | None:\n    \"\"\"\n    Query task status.\n    - If task is completed, return task result.\n    - If task is not completed, return None.\n    \"\"\"\n    task_query_url = os.getenv(const.XIAOWU_RPA_TASK_QUERY_URL_KEY, None)\n    if not is_valid_url(task_query_url):\n        logger.error(f\"Invalid task query URL: {task_query_url}\")\n        raise InvalidConfigException(f\"Invalid task query URL: {task_query_url}\")\n\n    async with httpx.AsyncClient() as client:\n        try:\n            response = await client.get(\n                url=f\"{task_query_url}/{task_id}\",\n                headers={\"Authorization\": f\"Bearer {access_token}\"},\n            )\n            response.raise_for_status()\n\n            response_data = response.json()\n            logger.debug(f\"query task response_data:\\n {response_data}\\n\\n\")\n\n            code = response_data.get(\"code\", \"-1\")\n            msg = response_data.get(\"msg\", None)\n            data = response_data.get(\"data\", None)\n            if code != \"0000\" or not data:\n                logger.error(f\"Task status query failed: {msg}\")\n                raise HTTPException(","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/plugin/rpa/infra/xiaowu/tasks.py#L86-L122","documentation":"query_task_status raises InvalidConfigException when the XIAOWU_RPA_TASK_QUERY_URL environment variable is unset or not a valid URL. It is a startup/configuration guard, not a runtime HTTP failure — the query is never sent.","triggerScenarios":"os.getenv(const.XIAOWU_RPA_TASK_QUERY_URL_KEY) returns None, an empty string, or a string failing is_valid_url (no scheme/host) before any HTTP call.","commonSituations":"Env var not set in the deployment (missing from docker-compose/k8s env), typo in the variable name, value set without scheme (e.g. 'rpa-api/query' instead of 'http://host/query'), trailing whitespace or quotes around the value.","solutions":["Set XIAOWU_RPA_TASK_QUERY_URL_KEY to a full URL including scheme, e.g. http://xiaowu-host/api/task/query","Check docker-compose/helm env configuration for the service actually receiving the variable","Strip whitespace/quotes from the configured value","Add a config validation at service startup so this fails fast with a clear message"],"exampleFix":"// before\ntask_query_url = os.getenv(const.XIAOWU_RPA_TASK_QUERY_URL_KEY, None)\n// after\n# .env\ntask_query_url = os.getenv(const.XIAOWU_RPA_TASK_QUERY_URL_KEY, None)\nif task_query_url:\n    task_query_url = task_query_url.strip().strip('\"').strip(\"'\")","handlingStrategy":"validation","validationCode":"from urllib.parse import urlparse\ndef is_valid_url(u):\n    if not u: return False\n    p = urlparse(u)\n    return p.scheme in (\"http\", \"https\") and bool(p.netloc)\n\nurl = os.getenv(\"XIAOWU_RPA_TASK_QUERY_URL_KEY\")\nassert is_valid_url(url), f\"Invalid task query URL: {url}\"","typeGuard":"def is_valid_url(u: str | None) -> bool:\n    from urllib.parse import urlparse\n    if not u: return False\n    p = urlparse(u)\n    return p.scheme in (\"http\", \"https\") and bool(p.netloc)","tryCatchPattern":null,"preventionTips":["Declare and validate all required env vars at service startup","Include the URL in the env template (.env.example) with scheme shown","Strip whitespace/quotes when reading env values","Fail fast with a clear message instead of at first use"],"tags":["config","env-var","url"],"backgroundTag":"invalid-url","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"}