iflytek/astron-agent · error · HTTPException

Task status query failed

Error message

Task status query failed: {code}:{msg}

What it means

query_task_status raises HTTPException(500) when the Xiaowu RPA backend returns a business code other than '0000' (or missing data) for a task-status query. The message embeds code and msg from the upstream API, e.g. invalid task id or backend error.

Solutions

  1. Check the upstream msg/code in logs for the concrete rejection reason
  2. Verify the task_id being queried actually exists upstream (was creation successful?)
  3. Validate the access token is valid and not expired
  4. Retry with backoff if the upstream code indicates a transient error

Example fix

// before
raise HTTPException(status_code=500, detail=f"Task status query failed: {code}:{msg}")
// after
raise HTTPException(status_code=500, detail=f"Task status query failed: {code}:{msg} task_id={task_id}")
Defensive patterns

Strategy: try-catch

Validate before calling

resp = await client.get(f"{query_url}/{task_id}", headers=headers)
body = resp.json()
if body.get("code") != "0000" or not body.get("data"):
    print(f"Query will fail upstream: {body.get('code')}:{body.get('msg')}")

Try / catch

try:
    result = await query_task_status(task_id, access_token)
except HTTPException as e:
    logger.warning(f"status query failed for {task_id}: {e.detail}")
    # verify task_id/token, or retry if transient

Prevention

When it happens

Trigger: GET {task_query_url}/{task_id} returns 200 with body code != '0000' or data == None.

Common situations: Invalid/expired task_id queried upstream, expired Bearer access token, upstream service degradation, task purged on the RPA side before status check.

Related errors


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

Appendix: source

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

        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(
                    status_code=500, detail=f"Task status query failed: {code}:{msg}"
                )

            execution = data.get("execution", {})
            if not execution:
                logger.error("Task status query failed: No task information returned")
                raise HTTPException(
                    status_code=500,
                    detail="Task status query failed: No task information returned",
                )

            status = execution.get("status", "")
            if status in ["COMPLETED"]:
                result = execution.get("result", {}) or {}
                r_code = result.get("code", "-1")
                r_msg = result.get("msg", "")
                r_data = result.get("data", {})
                return (

View on GitHub (pinned to 5e758547a8)