{"record":{"id":"31d5231566b0c578","repo":"iflytek/astron-agent","slug":"task-creation-failed-e-response-text","errorCode":null,"errorMessage":"Task creation failed: {e.response.text}","messagePattern":"Task creation failed: (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":null,"severity":"error","filePath":"core/plugin/rpa/infra/xiaowu/tasks.py","lineNumber":81,"sourceCode":"\n            if code != \"0000\" or not data:\n                logger.error(f\"Task creation failed: {msg}\")\n                raise HTTPException(\n                    status_code=500, detail=f\"Task creation failed: {msg}\"\n                )\n\n            task_id = data.get(\"executionId\", None)\n            if not task_id:\n                logger.error(\"Task creation failed: No task ID returned\")\n                raise HTTPException(\n                    status_code=500,\n                    detail=f\"Task creation failed: No task ID returned: {response_data}\",\n                )\n\n            return task_id\n        except httpx.HTTPStatusError as e:\n            logger.error(f\"Task creation failed: {e.response.text}\")\n            raise HTTPException(\n                status_code=e.response.status_code,\n                detail=f\"Task creation failed: {e.response.text}\",\n            ) from e\n        except Exception as e:\n            logger.error(f\"Task creation failed: {e}\")\n            raise HTTPException(\n                status_code=500, detail=f\"Task creation failed: {e}\"\n            ) from e\n\n\n# Query task status\nasync def query_task_status(\n    access_token: str, task_id: str\n) -> Tuple[int, str, dict] | None:\n    \"\"\"\n    Query task status.\n    - If task is completed, return task result.\n    - If task is not completed, return None.","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/plugin/rpa/infra/xiaowu/tasks.py#L63-L99","documentation":"create_task converts httpx.HTTPStatusError (non-2xx response from the Xiaowu API) into HTTPException carrying the upstream status code and response text. It means the HTTP request itself failed with a non-success status.","triggerScenarios":"httpx.AsyncClient.post(...).raise_for_status() raises because the RPA API returned 4xx/5xx (e.g. 401 unauthorized, 404 wrong URL, 502 gateway error).","commonSituations":"Misconfigured XIAOWU_RPA_TASK_CREATE_URL (wrong path/port), expired Bearer token causing 401, upstream 5xx during outage, gateway/proxy errors.","solutions":["Check e.response.text/status_code logged to identify the concrete HTTP failure","Verify the task-create URL env var points at the correct endpoint","Refresh/validate the access token used in the Authorization header","Confirm network/gateway path to the RPA service is healthy"],"exampleFix":"// before\nraise HTTPException(status_code=e.response.status_code, detail=f\"Task creation failed: {e.response.text}\") from e\n// after\n# keep mapping but truncate huge bodies and preserve cause\nraise HTTPException(status_code=e.response.status_code, detail=f\"Task creation failed: {e.response.text[:500]}\") from e","handlingStrategy":"try-catch","validationCode":"if not is_valid_url(task_create_url):\n    raise InvalidConfigException(f\"Invalid task create URL: {task_create_url}\")\n# also verify token non-empty before the call\nassert access_token, \"access token missing\"","typeGuard":null,"tryCatchPattern":"try:\n    task_id = await create_task(payload)\nexcept HTTPException as e:\n    if e.status_code in (429, 502, 503, 504):\n        schedule_retry(backoff=True)\n    elif e.status_code == 401:\n        refresh_token_and_retry()\n    else:\n        raise","preventionTips":["Validate the create-URL env var at startup","Rotate/refresh Bearer tokens before expiry","Set explicit httpx timeouts","Monitor upstream 5xx rates"],"tags":["http","httpx","upstream-api"],"backgroundTag":"http-error-response","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-19T12:17:13.211Z"}