{"record":{"id":"edd6ab28dd24d6b3","repo":"invoke-ai/InvokeAI","slug":"dashscope-task-task-id-failed-message","errorCode":null,"errorMessage":"DashScope task {task_id} failed: {message}","messagePattern":"DashScope task (.+?) failed: (.+?)","errorType":"exception","errorClass":"ExternalProviderRequestError","httpStatus":null,"severity":"error","filePath":"invokeai/app/services/external_generation/providers/alibabacloud.py","lineNumber":207,"sourceCode":"            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)\n            time.sleep(_TASK_POLL_INTERVAL)\n\n    def _parse_sync_response(\n        self,\n        data: dict[str, object],\n        request: ExternalGenerationRequest,\n        request_id: str | None,\n    ) -> ExternalGenerationResult:\n        \"\"\"Parse the synchronous multimodal-generation response.\"\"\"\n        output = data.get(\"output\")\n        if not isinstance(output, dict):\n            raise ExternalProviderRequestError(f\"DashScope response missing output: {data}\")\n\n        choices = output.get(\"choices\")\n        if not isinstance(choices, list):\n            raise ExternalProviderRequestError(f\"DashScope response missing choices: {data}\")","sourceCodeStart":189,"sourceCodeEnd":225,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/services/external_generation/providers/alibabacloud.py#L189-L225","documentation":"When the polled DashScope task reaches terminal status FAILED or UNKNOWN, _poll_task raises ExternalProviderRequestError embedding the task id and DashScope's output.message (or 'Unknown error'). The HTTP machinery worked; the generation itself failed on the provider side.","triggerScenarios":"Poll loop observes output.task_status == 'FAILED' or 'UNKNOWN'; message comes from output.get('message'). Common underlying causes are content-policy rejections, invalid generation parameters accepted at submit time but failing at execution, or provider internal errors.","commonSituations":"Prompt flagged by DashScope content moderation; image size/seed parameters invalid for the model at run time; provider internal errors during rendering; UNKNOWN status from malformed task state after an incident.","solutions":["Read output.message in the error text — DashScope's message states the failure reason (e.g. content policy, invalid parameter)","Adjust the prompt to avoid content-moderation rejections and resubmit","Validate parameters (size, model-specific options) against the model's constraints and retry","If UNKNOWN or repeated internal errors, retry later or contact Alibaba Cloud support with the task_id"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"# screen prompts client-side before submission to reduce content-policy failures\nif contains_flagged_terms(request.prompt):\n    raise ValueError(\"prompt likely rejected by DashScope moderation\")","typeGuard":null,"tryCatchPattern":"try:\n    result = provider.generate(request)\nexcept ExternalProviderRequestError as e:\n    if 'failed:' in str(e) and 'DashScope task' in str(e):\n        log.warning(\"DashScope task failed: %s\", e)\n        result = fallback_provider.generate(request)  # or retry once with sanitized prompt\n    else:\n        raise","preventionTips":["Read the embedded output.message to classify the failure before retrying","Sanitize/adjust prompts to pass content moderation","Validate model-specific parameters (size, seed) before submission","Configure a fallback provider for non-transient task failures"],"tags":["remote-task-failure","dashscope","alibabacloud","async","content-policy"],"backgroundTag":"remote-task-failed","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}