calesthio/OpenMontage · error · AtlasError

Atlas Cloud returned an unexpected 'data' field: {str(data)[

Error message

Atlas Cloud returned an unexpected 'data' field: {str(data)[:500]}

What it means

Raised by _payload_of when the envelope has code 200 but its data field is not a JSON object (array, string, number, or boolean). This catches servers that acknowledge success yet attach a malformed data payload, breaking the downstream dict access (data.get('id'), data.get('status')). The offending value's first 500 characters are included.

Source

Thrown at tools/atlas_client.py:94

        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:
    """Submit a generation request and return its prediction id."""
    import requests

    try:
        response = requests.post(
            endpoint, headers=_headers(api_key), json=payload, timeout=timeout
        )

View on GitHub (pinned to 95e1c3d0ab)

Solutions

  1. Log the included snippet to identify the actual shape, then compare with current Atlas API docs
  2. If the shape is a legitimate new format, update the client handling for that endpoint instead of relying on the generic parser
  3. Pin/request a stable API version header if Atlas exposes one
  4. Report to Atlas support if HTTP 200 + code 200 + non-dict data appears on their standard endpoints
Defensive patterns

Strategy: validation

Type guard

def has_dict_data(body: dict) -> bool:
    data = body.get("data")
    return data is None or isinstance(data, dict)

Prevention

When it happens

Trigger: A poll returning data as a list of output URLs; a submit response with data as a bare prediction-id string; API version drift where data became a nested array per output format.

Common situations: Atlas API evolution changing the data shape; middleboxes rewriting responses; endpoints that legitimately return non-object data being routed through this generic client.

Related errors


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