HKUDS/nanobot · error · ImageGenerationError
ModelScope did not return a task_id
Error message
ModelScope did not return a task_id: {response.text[:500]} What it means
Raised in ModelScopeImageGenerator._generate_with_client after a 2xx submission response whose JSON body lacks a task_id. The async task API is expected to return task_id; its absence means the response shape is unexpected (API contract change or unexpected payload), so the polling phase cannot proceed.
Solutions
- Log/inspect the full response body to see what ModelScope actually returned
- Verify the ModelScope image_generation endpoint version/API contract
- Update parsing if the API response schema changed
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at nanobot/providers/image_generation.py:2045 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of HKUDS/nanobot@42f37dc4c0 (2026-08-26).
Data as JSON: /api/errors/04d4d3e2147c1a6f.
Report an issue: GitHub.
Appendix: source
Thrown at nanobot/providers/image_generation.py:2045
body: dict[str, Any],
) -> GeneratedImageResponse:
try:
response = await client.post(url, headers=headers, json=body)
except httpx.TimeoutException as exc:
raise ImageGenerationError("ModelScope image generation request timed out") from exc
except httpx.RequestError as exc:
raise ImageGenerationError(f"ModelScope image generation request failed: {exc}") from exc
try:
response.raise_for_status()
except httpx.HTTPStatusError as exc:
detail = _http_error_detail(response)
raise ImageGenerationError(f"ModelScope image generation failed: {detail}") from exc
task_data = response.json()
task_id = task_data.get("task_id")
if not task_id:
raise ImageGenerationError(
f"ModelScope did not return a task_id: {response.text[:500]}"
)
images = await self._poll_task(client, task_id, headers)
self._require_images(images, task_data)
return GeneratedImageResponse(images=images, content="", raw=task_data)
async def _poll_task(
self,
client: httpx.AsyncClient,
task_id: str,
submit_headers: dict[str, str],
) -> list[str]:
poll_headers = {
"Authorization": submit_headers["Authorization"],
"X-ModelScope-Task-Type": "image_generation",
**self.extra_headers,View on GitHub (pinned to 42f37dc4c0)