{"record":{"id":"b1a9651d3bf0b4fc","repo":"iflytek/astron-agent","slug":"task-status-query-failed-no-task-information-returned","errorCode":null,"errorMessage":"Task status query failed: No task information returned","messagePattern":"Task status query failed: No task information returned","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"core/plugin/rpa/infra/xiaowu/tasks.py","lineNumber":129,"sourceCode":"            )\n            response.raise_for_status()\n\n            response_data = response.json()\n            logger.debug(f\"query task response_data:\\n {response_data}\\n\\n\")\n\n            code = response_data.get(\"code\", \"-1\")\n            msg = response_data.get(\"msg\", None)\n            data = response_data.get(\"data\", None)\n            if code != \"0000\" or not data:\n                logger.error(f\"Task status query failed: {msg}\")\n                raise HTTPException(\n                    status_code=500, detail=f\"Task status query failed: {code}:{msg}\"\n                )\n\n            execution = data.get(\"execution\", {})\n            if not execution:\n                logger.error(\"Task status query failed: No task information returned\")\n                raise HTTPException(\n                    status_code=500,\n                    detail=\"Task status query failed: No task information returned\",\n                )\n\n            status = execution.get(\"status\", \"\")\n            if status in [\"COMPLETED\"]:\n                result = execution.get(\"result\", {}) or {}\n                r_code = result.get(\"code\", \"-1\")\n                r_msg = result.get(\"msg\", \"\")\n                r_data = result.get(\"data\", {})\n                return (\n                    ErrorCode.SUCCESS.code,\n                    f\"{ErrorCode.SUCCESS.message}: {r_code}-{r_msg}\",\n                    r_data,\n                )\n\n            elif status in [\"FAILED\"]:\n                error = execution.get(\"error\", \"\")","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/plugin/rpa/infra/xiaowu/tasks.py#L111-L147","documentation":"query_task_status raises HTTPException(500) with 'No task information returned' when the upstream response carries code '0000' but data is missing/empty. The monitoring loop cannot determine task state without the data payload, so it treats the query as failed.","triggerScenarios":"response_data['code'] == '0000' but response_data['data'].get('execution') is {} or None.","commonSituations":"Upstream API contract change renaming/nesting the execution field, upstream returning success for unknown task IDs with empty payload, stub/mock environments with partial responses.","solutions":["Inspect the raw response to confirm the execution field name/location","Verify the API version/contract matches the caller's expectation","Confirm the task_id exists upstream (some APIs return empty data for unknown IDs)","Treat unknown task IDs distinctly (404-style) rather than generic 500"],"exampleFix":"// before\nexecution = data.get(\"execution\", {})\nif not execution:\n    raise HTTPException(status_code=500, detail=\"Task status query failed: No task information returned\")\n// after\nexecution = data.get(\"execution\") or {}\nif not execution:\n    raise HTTPException(status_code=404, detail=f\"Task status query failed: No execution info for task {task_id}\")","handlingStrategy":"validation","validationCode":"data = body.get(\"data\") or {}\nexecution = data.get(\"execution\") or {}\nassert execution, f\"Success envelope missing execution: {body}\"","typeGuard":"def has_execution(data: dict | None) -> bool:\n    return bool(isinstance(data, dict) and data.get(\"execution\"))","tryCatchPattern":null,"preventionTips":["Pin the upstream response contract in integration tests","Treat success-with-empty-execution as task-not-found","Watch for upstream API version changes","Avoid stub environments in production paths"],"tags":["http","api-contract","rpa"],"backgroundTag":"unexpected-api-response-shape","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"}