iflytek/astron-agent · error · HTTPException
Unknown task status
Error message
Unknown task status: {status} What it means
After mapping COMPLETED and PENDING statuses, any other status value returned by the execution falls through to this HTTPException(500). The caller only knows how to interpret COMPLETED/PENDING, so an unrecognized status is surfaced as an internal error.
Solutions
- Extend the status mapping to cover all documented upstream statuses (FAILED, RUNNING, CANCELLED, etc.)
- Check upstream docs/logs for the actual status string returned
- Normalize status casing before comparison (status.upper())
- Handle empty status explicitly instead of hitting the unknown branch
Example fix
// before
elif status in ["PENDING"]:
return None
raise HTTPException(status_code=500, detail=f"Unknown task status: {status}")
// after
elif status in ["PENDING", "RUNNING", "INIT"]:
return None
elif status in ["FAILED", "CANCELLED"]:
raise HTTPException(status_code=500, detail=f"Task ended with status {status}")
raise HTTPException(status_code=500, detail=f"Unknown task status: {status}") Defensive patterns
Strategy: validation
Validate before calling
KNOWN_STATUSES = {"COMPLETED", "PENDING", "RUNNING", "FAILED", "CANCELLED"}
status = (execution.get("status") or "").upper()
if status not in KNOWN_STATUSES:
raise ValueError(f"Unsupported upstream status: {status!r}") Type guard
def is_known_status(s: str) -> bool:
return isinstance(s, str) and s.upper() in {"COMPLETED", "PENDING", "RUNNING", "FAILED", "CANCELLED"} Prevention
- Normalize status casing before comparisons
- Subscribe to upstream API changelogs for new statuses
- Cover every documented status in unit tests
- Fail explicitly on empty status values
When it happens
Trigger: execution.status is a value not in ['COMPLETED'] or ['PENDING'] — e.g. 'FAILED', 'RUNNING', 'CANCELLED', lowercase variants, or empty string.
Common situations: Upstream adds new status values (RUNNING/FAILED/CANCELLED) the integration never learned about, status casing differences, empty status from a contract change.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Task creation failed: No task ID returned
- Task status query failed: No task information returned
- 40024
- 8309
- 8310
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/a80ec1473e1a14da.
Report an issue: GitHub.
Appendix: source
Thrown at core/plugin/rpa/infra/xiaowu/tasks.py:168
return (
ErrorCode.TASK_EXEC_FAILED.code,
f"{ErrorCode.TASK_EXEC_FAILED.message}: {error}",
{},
)
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)