invoke-ai/InvokeAI · error · ExternalProviderRequestError

DashScope async response missing task_id: {data}

Error message

DashScope async response missing task_id: {data}

What it means

After a successful async submit, the provider expects data['output']['task_id'] to identify the created task. If the response body has no task_id, the contract is violated and _generate_async raises ExternalProviderRequestError including the full response for debugging. This guards against schema changes or partial successes that return 2xx without a task.

Source

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

            "input": input_data,
            "parameters": parameters,
        }

        response = self._post_with_retry(
            endpoint, headers=async_headers, json=payload, timeout=60, label="DashScope async submit"
        )
        if not response.ok:
            raise ExternalProviderRequestError(
                f"DashScope async request failed with status {response.status_code} for model '{model_id}': {response.text}"
            )

        data = response.json()
        request_id = data.get("request_id")
        output = data.get("output", {})
        task_id = output.get("task_id")

        if not task_id:
            raise ExternalProviderRequestError(f"DashScope async response missing task_id: {data}")

        return self._poll_task(base_url, headers, task_id, request, request_id)

    def _poll_task(
        self,
        base_url: str,
        headers: dict[str, str],
        task_id: str,
        request: ExternalGenerationRequest,
        request_id: str | None,
    ) -> ExternalGenerationResult:
        """Poll an async task until completion."""
        task_url = f"{base_url}/api/v1/tasks/{task_id}"
        start_time = time.monotonic()
        poll_headers = {"Authorization": headers["Authorization"]}
        first_poll = True

        while True:

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Inspect the printed response data in the message — it usually contains an error code/message explaining why no task was created
  2. Verify external_alibabacloud_base_url points at the correct DashScope endpoint (correct region, https)
  3. Check for auth/quota issues that DashScope reports in-body with HTTP 200
  4. Upgrade InvokeAI or patch alibabacloud.py if DashScope changed its response schema
Defensive patterns

Strategy: try-catch

Validate before calling

# ensure correct regional endpoint before calling
assert (app_config.external_alibabacloud_base_url or 'https://dashscope-intl.aliyuncs.com').startswith('https://dashscope')

Type guard

def has_task_id(resp_data: dict) -> bool:
    return bool(resp_data.get('output', {}).get('task_id'))

Try / catch

try:
    result = provider.generate(request)
except ExternalProviderRequestError as e:
    if 'missing task_id' in str(e):
        body = str(e)
        log.error("DashScope contract violation, body: %s", body)
        if 'InvalidApi' in body or 'quota' in body.lower():
            fix_credentials_or_quota()
    raise

Prevention

When it happens

Trigger: DashScope returns HTTP 2xx but the JSON lacks output.task_id — e.g. output is an error object with code/message, an empty output {}, or a schema change in the DashScope async API.

Common situations: DashScope returns 200 with an embedded error (quota/auth issues surfaced in-body); DashScope API schema update; proxy/gateway returning an unexpected 2xx HTML/JSON body; misconfigured base_url pointing at a non-DashScope endpoint.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


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