calesthio/OpenMontage · error · AtlasError

Atlas Cloud error (code {code}): {message}

Error message

Atlas Cloud error (code {code}): {message}

What it means

Raised by _payload_of when the Atlas envelope's application-level code field is present and not 200 — even when the HTTP status itself is 200. Atlas reports business errors (auth, insufficient credits, invalid model, parameter rejection) inside the envelope, so this check is what actually surfaces them. The message prefers body.message, then body.error, then a truncated dump.

Source

Thrown at tools/atlas_client.py:87

def _payload_of(response: Any) -> dict[str, Any]:
    """Parse an Atlas envelope, raising AtlasError with the body on any problem.

    Atlas wraps results as {"code": 200, "data": {...}}. A non-200 `code` can ride
    along with HTTP 200, so the envelope is checked even on a successful request.
    """
    try:
        body = response.json()
    except Exception as exc:  # noqa: BLE001 - surface the raw text, not a parse trace
        text = getattr(response, "text", "")
        raise AtlasError(f"Atlas Cloud returned a non-JSON response: {text[:500]}") from exc

    if not isinstance(body, dict):
        raise AtlasError(f"Atlas Cloud returned an unexpected payload: {str(body)[:500]}")

    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:

View on GitHub (pinned to 95e1c3d0ab)

Solutions

  1. Read the embedded message — auth codes mean refresh the Atlas API key, credit codes mean top up the account
  2. Log the full response body (minus auth headers) at the call site for the exact rejection reason
  3. Validate payload fields (model slug, aspect ratio, duration) against current Atlas docs before submitting
  4. For credit/auth issues, add a preflight balance or key check if the API offers one
Defensive patterns

Strategy: try-catch

Try / catch

try:
    data = _payload_of(resp)
except AtlasError as e:
    msg = str(e)
    if "Atlas Cloud error (code" in msg:
        # business rejection — inspect code, do NOT blind-retry
        logger.error("Atlas rejected request: %s", msg)
        raise
    raise

Prevention

When it happens

Trigger: Submitting a generation with an invalid/expired API key (envelope code for unauthorized); insufficient credits or plan restrictions on a premium model; invalid payload fields (bad aspect_ratio, unknown model slug); a poll response where the platform wrapped an error with HTTP 200.

Common situations: Rotated API key not refreshed in env; free-tier credit exhaustion mid-render; typos in model endpoint slugs; region-locked models requested from an unsupported account.

Related errors


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