iflytek/astron-agent · error · HTTPException

Task status query failed

Error message

Task status query failed: {e}

What it means

Catch-all in query_task_status: any exception not handled earlier (network errors, the HTTPStatusError path if present, JSON issues, even the Unknown-status HTTPException re-raised) is logged and wrapped as HTTPException(500) 'Task status query failed'.

Solutions

  1. Inspect the logged '{e}' message to find the root cause (connect error, timeout, decode)
  2. Check network connectivity and timeout settings for the query endpoint
  3. Validate upstream returns JSON with the expected envelope
  4. Distinguish already-wrapped HTTPExceptions from new failures to avoid double-wrapping

Example fix

// before
except Exception as e:
    logger.error(f"Task status query failed: {e}")
    raise HTTPException(status_code=500, detail=f"Task status query failed: {e}") from e
// after
except HTTPException:
    raise  # do not double-wrap already-classified errors
except Exception as e:
    logger.exception("Task status query failed")
    raise HTTPException(status_code=500, detail=f"Task status query failed: {e}") from e
Defensive patterns

Strategy: try-catch

Validate before calling

socket.gethostbyname(host)  # verify query endpoint reachable before polling

Try / catch

try:
    result = await query_task_status(task_id, token)
except HTTPException as e:
    logger.warning(f"query failed: {e.detail}")
    await asyncio.sleep(backoff)
    # retry or mark task state unknown

Prevention

When it happens

Trigger: httpx connect/timeout errors during GET, non-JSON response body causing .json() to raise, or any other unexpected exception inside the try block.

Common situations: RPA query service unreachable, request timeouts, upstream returning HTML error pages instead of JSON, regressions surfacing as this generic wrapper.

Understand the failure class

Background: "API request failed": what wrapped HTTP errors from external APIs mean and how to find the real cause — this error's family across 29 libraries.

Related errors


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

Appendix: source

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

                r_code = result.get("code", "-1")
                r_msg = result.get("msg", "")
                r_data = result.get("data", {})
                return (
                    ErrorCode.TASK_EXEC_FAILED.code,
                    f"{ErrorCode.TASK_EXEC_FAILED.message}: {r_code}-{r_msg}",
                    r_data or {},
                )

            elif status in ["PENDING"]:
                return None

            raise HTTPException(
                status_code=500, detail=f"Unknown task status: {status}"
            )

        except Exception as e:
            logger.error(f"Task status query failed: {e}")
            raise HTTPException(
                status_code=500, detail=f"Task status query failed: {e}"
            ) from e

View on GitHub (pinned to 5e758547a8)