{"record":{"id":"7b423e1db5ec8a3d","repo":"invoke-ai/InvokeAI","slug":"dashscope-async-response-missing-task-id-data","errorCode":null,"errorMessage":"DashScope async response missing task_id: {data}","messagePattern":"DashScope async response missing task_id: (.+?)","errorType":"exception","errorClass":"ExternalProviderRequestError","httpStatus":null,"severity":"error","filePath":"invokeai/app/services/external_generation/providers/alibabacloud.py","lineNumber":166,"sourceCode":"            \"input\": input_data,\n            \"parameters\": parameters,\n        }\n\n        response = self._post_with_retry(\n            endpoint, headers=async_headers, json=payload, timeout=60, label=\"DashScope async submit\"\n        )\n        if not response.ok:\n            raise ExternalProviderRequestError(\n                f\"DashScope async request failed with status {response.status_code} for model '{model_id}': {response.text}\"\n            )\n\n        data = response.json()\n        request_id = data.get(\"request_id\")\n        output = data.get(\"output\", {})\n        task_id = output.get(\"task_id\")\n\n        if not task_id:\n            raise ExternalProviderRequestError(f\"DashScope async response missing task_id: {data}\")\n\n        return self._poll_task(base_url, headers, task_id, request, request_id)\n\n    def _poll_task(\n        self,\n        base_url: str,\n        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:","sourceCodeStart":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/services/external_generation/providers/alibabacloud.py#L148-L184","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Inspect the printed response data in the message — it usually contains an error code/message explaining why no task was created","Verify external_alibabacloud_base_url points at the correct DashScope endpoint (correct region, https)","Check for auth/quota issues that DashScope reports in-body with HTTP 200","Upgrade InvokeAI or patch alibabacloud.py if DashScope changed its response schema"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"# ensure correct regional endpoint before calling\nassert (app_config.external_alibabacloud_base_url or 'https://dashscope-intl.aliyuncs.com').startswith('https://dashscope')","typeGuard":"def has_task_id(resp_data: dict) -> bool:\n    return bool(resp_data.get('output', {}).get('task_id'))","tryCatchPattern":"try:\n    result = provider.generate(request)\nexcept ExternalProviderRequestError as e:\n    if 'missing task_id' in str(e):\n        body = str(e)\n        log.error(\"DashScope contract violation, body: %s\", body)\n        if 'InvalidApi' in body or 'quota' in body.lower():\n            fix_credentials_or_quota()\n    raise","preventionTips":["Verify base_url points at the correct DashScope region endpoint","Watch for DashScope API schema changes after provider-side updates","Handle in-body errors (HTTP 200 + error object) via monitoring/alerting on this error"],"tags":["schema","api-contract","dashscope","alibabacloud","async","response-parsing"],"backgroundTag":"schema-validation-failed","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}