calesthio/OpenMontage · error · AtlasError

{context} failed with HTTP {status}: {text[:500]}

Error message

{context} failed with HTTP {status}: {text[:500]}

What it means

Raised by _raise_for_status when an Atlas HTTP response has status >= 400, prefixing the operation context ('Atlas Cloud submission', 'Atlas Cloud poll for <id>', 'Atlas Cloud upload', 'Atlas Cloud output download') plus status and first 500 chars of body. It is the transport-level error path, complementary to the envelope-level code check in _payload_of.

Source

Thrown at tools/atlas_client.py:102

    code = body.get("code")
    if code is not None and int(code) != 200:
        message = body.get("message") or body.get("error") or str(body)[:500]
        raise AtlasError(f"Atlas Cloud error (code {code}): {message}")

    data = body.get("data")
    if data is None:
        # uploadMedia historically answered with a bare {"url": ...}.
        return body
    if not isinstance(data, dict):
        raise AtlasError(f"Atlas Cloud returned an unexpected 'data' field: {str(data)[:500]}")
    return data


def _raise_for_status(response: Any, context: str) -> None:
    status = getattr(response, "status_code", 200)
    if status >= 400:
        text = getattr(response, "text", "")
        raise AtlasError(f"{context} failed with HTTP {status}: {text[:500]}")


def submit(endpoint: str, payload: dict[str, Any], api_key: str, timeout: int = 60) -> str:
    """Submit a generation request and return its prediction id."""
    import requests

    try:
        response = requests.post(
            endpoint, headers=_headers(api_key), json=payload, timeout=timeout
        )
    except AtlasError:
        raise
    except Exception as exc:  # noqa: BLE001
        raise AtlasError(f"Could not reach Atlas Cloud at {endpoint}: {exc}") from exc

    _raise_for_status(response, "Atlas Cloud submission")
    data = _payload_of(response)

View on GitHub (pinned to 95e1c3d0ab)

Solutions

  1. Match on the HTTP status: 401/403 → fix API key; 404 → the prediction id is gone, resubmit; 413 → compress/resize the file; 429 → back off
  2. For 5xx, retry with exponential backoff — transient on generation platforms
  3. Verify the prediction id is from a recent submit and wasn't truncated when copied
  4. Check request size limits against your media file before upload
Defensive patterns

Strategy: retry

Try / catch

try:
    resp = requests.get(url, headers=headers, timeout=30)
    _raise_for_status(resp, "poll")
except AtlasError as e:
    if "HTTP 5" in str(e) or "HTTP 429" in str(e):
        time.sleep(backoff); backoff *= 2
        continue  # retryable
    raise  # 4xx (auth/404) are permanent

Prevention

When it happens

Trigger: 401/403 from a bad API key on submit/poll/upload; 404 from polling a prediction id that expired or never existed; 413 from uploading an oversized media file; 429 from rate limiting; 500/502/504 from Atlas-side failures.

Common situations: API key expired or revoked between submit and poll; retrying after a prediction retention window lapsed so GET /predictions/<id> 404s; uploading a video above the endpoint size cap; bursts of polls tripping rate limits.

Related errors


AI-assisted analysis of calesthio/OpenMontage@95e1c3d0ab (2026-08-15). Data as JSON: /api/errors/c393096bb265430c. Report an issue: GitHub.