iflytek/astron-agent · error · HTTPException

Task creation failed

Error message

Task creation failed: {msg}

What it means

create_task in the Xiaowu RPA integration raises HTTPException(500) when the remote task-creation API responds with code != '0000' or an empty data payload. It means the upstream RPA service rejected or returned no usable result for the creation request.

Solutions

  1. Log the full response body and check the upstream msg for the concrete API error
  2. Verify XIAOWU_RPA_TASK_CREATE_URL config and that the service is reachable/healthy
  3. Check the access token passed in Authorization header is valid and not expired
  4. Add retry with backoff for transient upstream failures

Example fix

// before
raise HTTPException(status_code=500, detail=f"Task creation failed: {msg}")
// after
# surface the upstream code too for easier diagnosis
raise HTTPException(status_code=500, detail=f"Task creation failed: code={code} msg={msg}")
Defensive patterns

Strategy: try-catch

Validate before calling

resp = await client.post(url, json=payload, headers=headers)
body = resp.json()
if body.get("code") != "0000" or not body.get("data"):
    print(f"Upstream will reject creation: {body.get('code')}:{body.get('msg')}")

Try / catch

try:
    task_id = await create_task(payload)
except HTTPException as e:
    logger.error(f"create_task rejected: {e.detail}")
    # surface to user / retry with backoff if transient

Prevention

When it happens

Trigger: POST to the Xiaowu task-creation URL succeeds at HTTP level but the JSON body has code != '0000' or data is None/empty.

Common situations: Upstream RPA service outages or partial degradation, invalid request payload rejected by the API, expired/invalid access token surfaced as an API-level code, or upstream maintenance returning error envelopes.

Related errors


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

Appendix: source

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

    async with httpx.AsyncClient() as client:
        try:
            assert task_create_url is not None
            logger.info(
                f"create_task_url:{task_create_url} header:{header}, body:{body}"
            )
            response = await client.post(task_create_url, headers=header, json=body)
            response.raise_for_status()

            response_data = response.json()
            logger.debug(f"create 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 creation failed: {msg}")
                raise HTTPException(
                    status_code=500, detail=f"Task creation failed: {msg}"
                )

            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

View on GitHub (pinned to 5e758547a8)