{"record":{"id":"47c1e2ac19bdc6a5","repo":"iflytek/astron-agent","slug":"task-status-query-failed-code-msg","errorCode":null,"errorMessage":"Task status query failed: {code}:{msg}","messagePattern":"Task status query failed: (.+?):(.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"core/plugin/rpa/infra/xiaowu/tasks.py","lineNumber":122,"sourceCode":"        raise InvalidConfigException(f\"Invalid task query URL: {task_query_url}\")\n\n    async with httpx.AsyncClient() as client:\n        try:\n            response = await client.get(\n                url=f\"{task_query_url}/{task_id}\",\n                headers={\"Authorization\": f\"Bearer {access_token}\"},\n            )\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 (","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/plugin/rpa/infra/xiaowu/tasks.py#L104-L140","documentation":"query_task_status raises HTTPException(500) when the Xiaowu RPA backend returns a business code other than '0000' (or missing data) for a task-status query. The message embeds code and msg from the upstream API, e.g. invalid task id or backend error.","triggerScenarios":"GET {task_query_url}/{task_id} returns 200 with body code != '0000' or data == None.","commonSituations":"Invalid/expired task_id queried upstream, expired Bearer access token, upstream service degradation, task purged on the RPA side before status check.","solutions":["Check the upstream msg/code in logs for the concrete rejection reason","Verify the task_id being queried actually exists upstream (was creation successful?)","Validate the access token is valid and not expired","Retry with backoff if the upstream code indicates a transient error"],"exampleFix":"// before\nraise HTTPException(status_code=500, detail=f\"Task status query failed: {code}:{msg}\")\n// after\nraise HTTPException(status_code=500, detail=f\"Task status query failed: {code}:{msg} task_id={task_id}\")","handlingStrategy":"try-catch","validationCode":"resp = await client.get(f\"{query_url}/{task_id}\", headers=headers)\nbody = resp.json()\nif body.get(\"code\") != \"0000\" or not body.get(\"data\"):\n    print(f\"Query will fail upstream: {body.get('code')}:{body.get('msg')}\")","typeGuard":null,"tryCatchPattern":"try:\n    result = await query_task_status(task_id, access_token)\nexcept HTTPException as e:\n    logger.warning(f\"status query failed for {task_id}: {e.detail}\")\n    # verify task_id/token, or retry if transient","preventionTips":["Only query task_ids returned by a successful create call","Refresh access tokens before expiry","Handle transient upstream codes with backoff retries","Log full response envelopes for support"],"tags":["http","upstream-api","rpa"],"backgroundTag":"api-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"}