{"record":{"id":"4e3a9276feb295e0","repo":"invoke-ai/InvokeAI","slug":"dashscope-task-poll-failed-with-status-response-s","errorCode":null,"errorMessage":"DashScope task poll failed with status {response.status_code}: {response.text}","messagePattern":"DashScope task poll failed with status (.+?): (.+?)","errorType":"exception","errorClass":"ExternalProviderRequestError","httpStatus":null,"severity":"error","filePath":"invokeai/app/services/external_generation/providers/alibabacloud.py","lineNumber":191,"sourceCode":"        headers: dict[str, str],\n        task_id: str,\n        request: ExternalGenerationRequest,\n        request_id: str | None,\n    ) -> ExternalGenerationResult:\n        \"\"\"Poll an async task until completion.\"\"\"\n        task_url = f\"{base_url}/api/v1/tasks/{task_id}\"\n        start_time = time.monotonic()\n        poll_headers = {\"Authorization\": headers[\"Authorization\"]}\n        first_poll = True\n\n        while True:\n            elapsed = time.monotonic() - start_time\n            if elapsed > _TASK_POLL_TIMEOUT:\n                raise ExternalProviderRequestError(f\"DashScope task {task_id} timed out after {_TASK_POLL_TIMEOUT}s\")\n\n            response = self._get_with_retry(task_url, headers=poll_headers, timeout=30, label=\"DashScope task poll\")\n            if not response.ok:\n                raise ExternalProviderRequestError(\n                    f\"DashScope task poll failed with status {response.status_code}: {response.text}\"\n                )\n\n            data = response.json()\n            output = data.get(\"output\", {})\n            status = output.get(\"task_status\")\n\n            if first_poll:\n                self._logger.info(\"DashScope task %s submitted (status=%s)\", task_id, status)\n                first_poll = False\n\n            if status == \"SUCCEEDED\":\n                return self._parse_async_response(output, request, request_id)\n            if status in (\"FAILED\", \"UNKNOWN\"):\n                message = output.get(\"message\", \"Unknown error\")\n                raise ExternalProviderRequestError(f\"DashScope task {task_id} failed: {message}\")\n\n            self._logger.debug(\"DashScope task %s status: %s (%.0fs elapsed)\", task_id, status, elapsed)","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/services/external_generation/providers/alibabacloud.py#L173-L209","documentation":"Each poll iteration GETs the DashScope task status URL; if that HTTP request returns non-2xx, _poll_task raises ExternalProviderRequestError with the status code and response body, aborting the wait for the task. Distinct from 624/625 because it happens during polling, after successful submission.","triggerScenarios":"During polling, the task-status GET returns 4xx/5xx — auth header rejected (401), task URL wrong/expired (404), throttled polls (429), or DashScope errors (5xx).","commonSituations":"API key rotated/revoked while a task is in flight; base_url misconfiguration producing wrong task URLs; poll interval triggering rate limits; transient DashScope instability mid-poll.","solutions":["Check the status code/body in the message to identify the poll failure cause","Re-check the API key and base_url configuration (401/404 causes)","Slow down polling or retry the whole generation if throttled (429)","If 5xx persists, verify DashScope service health and resubmit the task"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if not api_key:\n    raise ConfigError(\"DashScope key missing\")  # 401 during polling otherwise\n# and confirm base_url is reachable:\n# HEAD base_url before long-running submissions","typeGuard":"def is_poll_http_error(e: Exception) -> bool:\n    return isinstance(e, ExternalProviderRequestError) and 'task poll failed with status' in str(e)","tryCatchPattern":"try:\n    result = provider.generate(request)\nexcept ExternalProviderRequestError as e:\n    if 'task poll failed' in str(e):\n        if 'status 401' in str(e):\n            refresh_key_and_resubmit(request)\n        elif 'status 429' in str(e):\n            slow_down_polling(); resubmit(request)\n        else:\n            raise","preventionTips":["Don't rotate/revoke keys while async tasks are in flight","Keep poll intervals modest to avoid throttling","Verify base_url region correctness before submitting long tasks"],"tags":["network","http-error","polling","dashscope","alibabacloud"],"backgroundTag":"http-4xx-error","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}