HKUDS/nanobot · error · ImageGenerationError

generated image exceeded the 32 MiB download limit

Error message

generated image exceeded the 32 MiB download limit

What it means

Size-limit guard in _download_image_data_url's streaming loop: cumulative downloaded bytes exceeded _IMAGE_DOWNLOAD_MAX_BYTES (32 MiB) mid-stream, so the read is aborted. Protects memory from runaway or malicious payloads masquerading as generated images.

Solutions

  1. Retry generation — legitimate images should be far below 32 MiB
  2. Lower resolution/size parameters for the image request
  3. If the model legitimately needs huge images, that exceeds the current hard limit and must be handled at provider side
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at nanobot/providers/image_generation.py:198 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/4a2da8fdb2ed9c5b. Report an issue: GitHub.

Appendix: source

Thrown at nanobot/providers/image_generation.py:198

                    )
                    if not ok:
                        raise ImageGenerationError(
                            f"blocked unsafe generated image URL: {error}"
                        )
                async with client.stream("GET", current_url) as response:
                    if response.is_redirect:
                        location = response.headers.get("location")
                        if not location:
                            raise ImageGenerationError(
                                "generated image URL redirected without a location"
                            )
                        current_url = urljoin(str(response.url), location)
                        continue

                    try:
                        response.raise_for_status()
                    except httpx.HTTPStatusError as exc:
                        raise ImageGenerationError(
                            f"failed to download generated image (HTTP {response.status_code})"
                        ) from exc

                    declared_size = response.headers.get("content-length")
                    if declared_size:
                        try:
                            if int(declared_size) > _IMAGE_DOWNLOAD_MAX_BYTES:
                                raise ImageGenerationError(
                                    "generated image exceeded the 32 MiB download limit"
                                )
                        except ValueError:
                            pass

                    chunks: list[bytes] = []
                    total = 0
                    async for chunk in response.aiter_bytes():
                        total += len(chunk)
                        if total > _IMAGE_DOWNLOAD_MAX_BYTES:

View on GitHub (pinned to 42f37dc4c0)