{"record":{"id":"b0cb054771a749c2","repo":"iflytek/astron-agent","slug":"task-status-query-failed-e","errorCode":null,"errorMessage":"Task status query failed: {e}","messagePattern":"Task status query failed: (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"core/plugin/rpa/infra/xiaowu/tasks.py","lineNumber":174,"sourceCode":"                r_code = result.get(\"code\", \"-1\")\n                r_msg = result.get(\"msg\", \"\")\n                r_data = result.get(\"data\", {})\n                return (\n                    ErrorCode.TASK_EXEC_FAILED.code,\n                    f\"{ErrorCode.TASK_EXEC_FAILED.message}: {r_code}-{r_msg}\",\n                    r_data or {},\n                )\n\n            elif status in [\"PENDING\"]:\n                return None\n\n            raise HTTPException(\n                status_code=500, detail=f\"Unknown task status: {status}\"\n            )\n\n        except Exception as e:\n            logger.error(f\"Task status query failed: {e}\")\n            raise HTTPException(\n                status_code=500, detail=f\"Task status query failed: {e}\"\n            ) from e\n","sourceCodeStart":156,"sourceCodeEnd":177,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/plugin/rpa/infra/xiaowu/tasks.py#L156-L177","documentation":"Catch-all in query_task_status: any exception not handled earlier (network errors, the HTTPStatusError path if present, JSON issues, even the Unknown-status HTTPException re-raised) is logged and wrapped as HTTPException(500) 'Task status query failed'.","triggerScenarios":"httpx connect/timeout errors during GET, non-JSON response body causing .json() to raise, or any other unexpected exception inside the try block.","commonSituations":"RPA query service unreachable, request timeouts, upstream returning HTML error pages instead of JSON, regressions surfacing as this generic wrapper.","solutions":["Inspect the logged '{e}' message to find the root cause (connect error, timeout, decode)","Check network connectivity and timeout settings for the query endpoint","Validate upstream returns JSON with the expected envelope","Distinguish already-wrapped HTTPExceptions from new failures to avoid double-wrapping"],"exampleFix":"// before\nexcept Exception as e:\n    logger.error(f\"Task status query failed: {e}\")\n    raise HTTPException(status_code=500, detail=f\"Task status query failed: {e}\") from e\n// after\nexcept HTTPException:\n    raise  # do not double-wrap already-classified errors\nexcept Exception as e:\n    logger.exception(\"Task status query failed\")\n    raise HTTPException(status_code=500, detail=f\"Task status query failed: {e}\") from e","handlingStrategy":"try-catch","validationCode":"socket.gethostbyname(host)  # verify query endpoint reachable before polling","typeGuard":null,"tryCatchPattern":"try:\n    result = await query_task_status(task_id, token)\nexcept HTTPException as e:\n    logger.warning(f\"query failed: {e.detail}\")\n    await asyncio.sleep(backoff)\n    # retry or mark task state unknown","preventionTips":["Add explicit httpx timeouts","Retry with backoff on transient network errors","Re-raise already-wrapped HTTPExceptions instead of double-wrapping","Log tracebacks (logger.exception) for root-cause analysis"],"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"}