{"record":{"id":"d8adf2f54ef760c9","repo":"invoke-ai/InvokeAI","slug":"seedream-response-payload-missing-image-data","errorCode":null,"errorMessage":"Seedream response payload missing image data","messagePattern":"Seedream response payload missing image data","errorType":"exception","errorClass":"ExternalProviderRequestError","httpStatus":null,"severity":"error","filePath":"invokeai/app/services/external_generation/providers/seedream.py","lineNumber":120,"sourceCode":"            if response.status_code == 429:\n                retry_after = _parse_retry_after(response.headers.get(\"retry-after\"))\n                raise ExternalProviderRateLimitError(\n                    f\"Seedream rate limit exceeded. {f'Retry after {retry_after:.0f}s.' if retry_after else 'Please try again later.'}\",\n                    retry_after=retry_after,\n                )\n            raise ExternalProviderRequestError(\n                f\"Seedream request failed with status {response.status_code}: {response.text}\"\n            )\n\n        body = response.json()\n        if not isinstance(body, dict):\n            raise ExternalProviderRequestError(\"Seedream response payload was not a JSON object\")\n\n        generated_images: list[ExternalGeneratedImage] = []\n        item_errors: list[dict[str, object]] = []\n        data_items = body.get(\"data\")\n        if not isinstance(data_items, list):\n            raise ExternalProviderRequestError(\"Seedream response payload missing image data\")\n\n        for item in data_items:\n            if not isinstance(item, dict):\n                continue\n            # Items may be error objects for failed images in batch — collect rather than discard\n            # so partial-failure causes (e.g., content filter) are visible to the caller.\n            if \"error\" in item:\n                error_payload = item[\"error\"]\n                item_errors.append(\n                    error_payload if isinstance(error_payload, dict) else {\"message\": str(error_payload)}\n                )\n                continue\n            encoded = item.get(\"b64_json\")\n            if not encoded:\n                continue\n            image = decode_image_base64(encoded)\n            generated_images.append(ExternalGeneratedImage(image=image, seed=request.seed))\n","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/services/external_generation/providers/seedream.py#L102-L138","documentation":"The Seedream external image-generation provider requires its HTTP response JSON to contain a top-level \"data\" array holding generated image objects. This error is raised when the response parsed as JSON but either omits \"data\" or has it as a non-list value (null, string, object). It signals that the provider's response shape does not match the expected API contract, so no images can be extracted.","triggerScenarios":"Calling ExternalProvider.generate() with a Seedream model when the provider returns JSON whose body.get(\"data\") is not a list — e.g. an error JSON body like {\"error\": {...}} without \"data\", a malformed/proxy response, or an API version whose payload shape changed.","commonSituations":"Expired or invalid API key causing the provider to return an error object instead of a generation payload; upstream API schema change; a gateway/load balancer returning JSON error pages; wrong model endpoint configured so responses come from a different API version.","solutions":["Verify the Seedream API key and account status so the provider returns a success payload rather than a JSON error object without \"data\"","Log the raw response body before parsing to confirm the actual payload shape and compare against the expected {\"data\": [...]} schema","Check the configured endpoint/model ID matches the Seedream API version in use (schema drift between versions)","Check for a proxy or gateway substituting its own JSON error responses"],"exampleFix":"// before\nbody = response.json()\ndata_items = body.get(\"data\")\n// after\nbody = response.json()\nif \"error\" in body:\n    raise ExternalProviderRequestError(f\"Seedream API error: {body['error']}\")\ndata_items = body.get(\"data\")","handlingStrategy":"type-guard","validationCode":"body = response.json()\nif not isinstance(body.get(\"data\"), list):\n    raise ValueError(f\"Seedream payload missing data array: {body}\")","typeGuard":"def has_data_array(body: object) -> bool:\n    return isinstance(body, dict) and isinstance(body.get(\"data\"), list)","tryCatchPattern":"try:\n    images = provider.generate(request)\nexcept ExternalProviderRequestError as e:\n    logger.error(f\"Seedream payload invalid: {e}\")\n    raise HTTPException(502, \"Image provider returned an invalid response\")","preventionTips":["Pin and test against the Seedream API version you configure","Log raw provider responses in staging to catch schema drift early","Validate API keys before deploying so error bodies don't masquerade as payloads"],"tags":["external-provider","api-contract","image-generation","response-validation"],"backgroundTag":"unexpected-api-response-shape","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}