iflytek/astron-agent · error · InvalidConfigException

Invalid task query URL

Error message

Invalid task query URL: {task_query_url}

What it means

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.

Solutions

  1. Set XIAOWU_RPA_TASK_QUERY_URL_KEY to a full URL including scheme, e.g. http://xiaowu-host/api/task/query
  2. Check docker-compose/helm env configuration for the service actually receiving the variable
  3. Strip whitespace/quotes from the configured value
  4. Add a config validation at service startup so this fails fast with a clear message

Example fix

// before
task_query_url = os.getenv(const.XIAOWU_RPA_TASK_QUERY_URL_KEY, None)
// after
# .env
task_query_url = os.getenv(const.XIAOWU_RPA_TASK_QUERY_URL_KEY, None)
if task_query_url:
    task_query_url = task_query_url.strip().strip('"').strip("'")
Defensive patterns

Strategy: validation

Validate before calling

from urllib.parse import urlparse
def is_valid_url(u):
    if not u: return False
    p = urlparse(u)
    return p.scheme in ("http", "https") and bool(p.netloc)

url = os.getenv("XIAOWU_RPA_TASK_QUERY_URL_KEY")
assert is_valid_url(url), f"Invalid task query URL: {url}"

Type guard

def is_valid_url(u: str | None) -> bool:
    from urllib.parse import urlparse
    if not u: return False
    p = urlparse(u)
    return p.scheme in ("http", "https") and bool(p.netloc)

Prevention

When it happens

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

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

Understand the failure class

Background: "Invalid URL" / "URL cannot be empty": fix the malformed or missing URL behind request-construction failures — this error's family across 50 libraries.

Related errors


AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12). Data as JSON: /api/errors/f8b8aad9b5609e64. Report an issue: GitHub.

Appendix: source

Thrown at core/plugin/rpa/infra/xiaowu/tasks.py:104

            logger.error(f"Task creation failed: {e}")
            raise HTTPException(
                status_code=500, detail=f"Task creation failed: {e}"
            ) from e


# Query task status
async def query_task_status(
    access_token: str, task_id: str
) -> Tuple[int, str, dict] | None:
    """
    Query task status.
    - If task is completed, return task result.
    - If task is not completed, return None.
    """
    task_query_url = os.getenv(const.XIAOWU_RPA_TASK_QUERY_URL_KEY, None)
    if not is_valid_url(task_query_url):
        logger.error(f"Invalid task query URL: {task_query_url}")
        raise InvalidConfigException(f"Invalid task query URL: {task_query_url}")

    async with httpx.AsyncClient() as client:
        try:
            response = await client.get(
                url=f"{task_query_url}/{task_id}",
                headers={"Authorization": f"Bearer {access_token}"},
            )
            response.raise_for_status()

            response_data = response.json()
            logger.debug(f"query task response_data:\n {response_data}\n\n")

            code = response_data.get("code", "-1")
            msg = response_data.get("msg", None)
            data = response_data.get("data", None)
            if code != "0000" or not data:
                logger.error(f"Task status query failed: {msg}")
                raise HTTPException(

View on GitHub (pinned to 5e758547a8)