invoke-ai/InvokeAI · error · ExternalProviderRequestError

DashScope task {task_id} failed: {message}

Error message

DashScope task {task_id} failed: {message}

What it means

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.

Source

Thrown at invokeai/app/services/external_generation/providers/alibabacloud.py:207

            response = self._get_with_retry(task_url, headers=poll_headers, timeout=30, label="DashScope task poll")
            if not response.ok:
                raise ExternalProviderRequestError(
                    f"DashScope task poll failed with status {response.status_code}: {response.text}"
                )

            data = response.json()
            output = data.get("output", {})
            status = output.get("task_status")

            if first_poll:
                self._logger.info("DashScope task %s submitted (status=%s)", task_id, status)
                first_poll = False

            if status == "SUCCEEDED":
                return self._parse_async_response(output, request, request_id)
            if status in ("FAILED", "UNKNOWN"):
                message = output.get("message", "Unknown error")
                raise ExternalProviderRequestError(f"DashScope task {task_id} failed: {message}")

            self._logger.debug("DashScope task %s status: %s (%.0fs elapsed)", task_id, status, elapsed)
            time.sleep(_TASK_POLL_INTERVAL)

    def _parse_sync_response(
        self,
        data: dict[str, object],
        request: ExternalGenerationRequest,
        request_id: str | None,
    ) -> ExternalGenerationResult:
        """Parse the synchronous multimodal-generation response."""
        output = data.get("output")
        if not isinstance(output, dict):
            raise ExternalProviderRequestError(f"DashScope response missing output: {data}")

        choices = output.get("choices")
        if not isinstance(choices, list):
            raise ExternalProviderRequestError(f"DashScope response missing choices: {data}")

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Read output.message in the error text — DashScope's message states the failure reason (e.g. content policy, invalid parameter)
  2. Adjust the prompt to avoid content-moderation rejections and resubmit
  3. Validate parameters (size, model-specific options) against the model's constraints and retry
  4. If UNKNOWN or repeated internal errors, retry later or contact Alibaba Cloud support with the task_id
Defensive patterns

Strategy: fallback

Validate before calling

# screen prompts client-side before submission to reduce content-policy failures
if contains_flagged_terms(request.prompt):
    raise ValueError("prompt likely rejected by DashScope moderation")

Try / catch

try:
    result = provider.generate(request)
except ExternalProviderRequestError as e:
    if 'failed:' in str(e) and 'DashScope task' in str(e):
        log.warning("DashScope task failed: %s", e)
        result = fallback_provider.generate(request)  # or retry once with sanitized prompt
    else:
        raise

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29). Data as JSON: /api/errors/edd6ab28dd24d6b3. Report an issue: GitHub.