iflytek/astron-agent · error · HTTPException
Task creation failed
Error message
Task creation failed: {e} What it means
Catch-all branch of create_task: any unexpected exception (network errors, timeouts, JSON decode failures, bugs) is wrapped into HTTPException(500) with the exception message. Indicates the task-creation request failed outside the handled API-error paths.
Solutions
- Inspect the logged exception to identify the root cause (connect vs timeout vs decode)
- Check network reachability and timeouts for the RPA service host
- Validate the request payload serializes to valid JSON
- Configure explicit httpx timeouts and retry transient network errors
Example fix
// before
except Exception as e:
logger.error(f"Task creation failed: {e}")
raise HTTPException(status_code=500, detail=f"Task creation failed: {e}") from e
// after
except (httpx.ConnectError, httpx.TimeoutException) as e:
logger.error(f"Task creation network failure: {e}")
raise HTTPException(status_code=503, detail="Task creation failed: upstream unreachable") from e
except Exception as e:
logger.exception("Task creation failed")
raise HTTPException(status_code=500, detail=f"Task creation failed: {e}") from e Defensive patterns
Strategy: try-catch
Validate before calling
import socket socket.gethostbyname(host) # fail fast if RPA host unresolvable before calling
Try / catch
try:
task_id = await create_task(payload)
except HTTPException as e:
logger.error(f"task creation failed: {e.detail}")
# decide: retry (network) vs surface (bug/config) Prevention
- Set explicit connect/read timeouts on httpx clients
- Use retry with exponential backoff for transient network errors
- Ensure payload is JSON-serializable before the call
- Log the exception traceback, not just str(e)
When it happens
Trigger: httpx.ConnectError/ReadTimeout/JSON decode error, or any other Exception raised inside create_task that is not HTTPStatusError.
Common situations: RPA service unreachable (DNS/firewall), connection timeouts under load, upstream returning non-JSON body causing .json() to fail, programming errors in payload construction.
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
- Task status query failed
- sandbox-exec failed: HTTP
- Skill resource download failed: HTTP
- MODEL_CHECK_FAILED
- REPO_KNOWLEDGE_DOWNLOAD_FAILED
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/fe0d7a5396ff3691.
Report an issue: GitHub.
Appendix: source
Thrown at core/plugin/rpa/infra/xiaowu/tasks.py:87
task_id = data.get("executionId", None)
if not task_id:
logger.error("Task creation failed: No task ID returned")
raise HTTPException(
status_code=500,
detail=f"Task creation failed: No task ID returned: {response_data}",
)
return task_id
except httpx.HTTPStatusError as e:
logger.error(f"Task creation failed: {e.response.text}")
raise HTTPException(
status_code=e.response.status_code,
detail=f"Task creation failed: {e.response.text}",
) from e
except Exception as e:
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}")
View on GitHub (pinned to 5e758547a8)