{"record":{"id":"fe0d7a5396ff3691","repo":"iflytek/astron-agent","slug":"task-creation-failed-e","errorCode":null,"errorMessage":"Task creation failed: {e}","messagePattern":"Task creation failed: (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"core/plugin/rpa/infra/xiaowu/tasks.py","lineNumber":87,"sourceCode":"\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.\n    \"\"\"\n    task_query_url = os.getenv(const.XIAOWU_RPA_TASK_QUERY_URL_KEY, None)\n    if not is_valid_url(task_query_url):\n        logger.error(f\"Invalid task query URL: {task_query_url}\")\n        raise InvalidConfigException(f\"Invalid task query URL: {task_query_url}\")\n","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/plugin/rpa/infra/xiaowu/tasks.py#L69-L105","documentation":"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.","triggerScenarios":"httpx.ConnectError/ReadTimeout/JSON decode error, or any other Exception raised inside create_task that is not HTTPStatusError.","commonSituations":"RPA service unreachable (DNS/firewall), connection timeouts under load, upstream returning non-JSON body causing .json() to fail, programming errors in payload construction.","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"],"exampleFix":"// before\nexcept Exception as e:\n    logger.error(f\"Task creation failed: {e}\")\n    raise HTTPException(status_code=500, detail=f\"Task creation failed: {e}\") from e\n// after\nexcept (httpx.ConnectError, httpx.TimeoutException) as e:\n    logger.error(f\"Task creation network failure: {e}\")\n    raise HTTPException(status_code=503, detail=\"Task creation failed: upstream unreachable\") from e\nexcept Exception as e:\n    logger.exception(\"Task creation failed\")\n    raise HTTPException(status_code=500, detail=f\"Task creation failed: {e}\") from e","handlingStrategy":"try-catch","validationCode":"import socket\nsocket.gethostbyname(host)  # fail fast if RPA host unresolvable before calling","typeGuard":null,"tryCatchPattern":"try:\n    task_id = await create_task(payload)\nexcept HTTPException as e:\n    logger.error(f\"task creation failed: {e.detail}\")\n    # decide: retry (network) vs surface (bug/config)","preventionTips":["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)"],"tags":["http","network","rpa"],"backgroundTag":"api-request-failed","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}