{"record":{"id":"c393096bb265430c","repo":"calesthio/OpenMontage","slug":"context-failed-with-http-status-text-500","errorCode":null,"errorMessage":"{context} failed with HTTP {status}: {text[:500]}","messagePattern":"(.+?) failed with HTTP (.+?): (.+?)","errorType":"http","errorClass":"AtlasError","httpStatus":null,"severity":"error","filePath":"tools/atlas_client.py","lineNumber":102,"sourceCode":"    code = body.get(\"code\")\n    if code is not None and int(code) != 200:\n        message = body.get(\"message\") or body.get(\"error\") or str(body)[:500]\n        raise AtlasError(f\"Atlas Cloud error (code {code}): {message}\")\n\n    data = body.get(\"data\")\n    if data is None:\n        # uploadMedia historically answered with a bare {\"url\": ...}.\n        return body\n    if not isinstance(data, dict):\n        raise AtlasError(f\"Atlas Cloud returned an unexpected 'data' field: {str(data)[:500]}\")\n    return data\n\n\ndef _raise_for_status(response: Any, context: str) -> None:\n    status = getattr(response, \"status_code\", 200)\n    if status >= 400:\n        text = getattr(response, \"text\", \"\")\n        raise AtlasError(f\"{context} failed with HTTP {status}: {text[:500]}\")\n\n\ndef submit(endpoint: str, payload: dict[str, Any], api_key: str, timeout: int = 60) -> str:\n    \"\"\"Submit a generation request and return its prediction id.\"\"\"\n    import requests\n\n    try:\n        response = requests.post(\n            endpoint, headers=_headers(api_key), json=payload, timeout=timeout\n        )\n    except AtlasError:\n        raise\n    except Exception as exc:  # noqa: BLE001\n        raise AtlasError(f\"Could not reach Atlas Cloud at {endpoint}: {exc}\") from exc\n\n    _raise_for_status(response, \"Atlas Cloud submission\")\n    data = _payload_of(response)\n","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/calesthio/OpenMontage/blob/95e1c3d0ab93482159818560f6a8c8e866b9139f/tools/atlas_client.py#L84-L120","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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","For 5xx, retry with exponential backoff — transient on generation platforms","Verify the prediction id is from a recent submit and wasn't truncated when copied","Check request size limits against your media file before upload"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    resp = requests.get(url, headers=headers, timeout=30)\n    _raise_for_status(resp, \"poll\")\nexcept AtlasError as e:\n    if \"HTTP 5\" in str(e) or \"HTTP 429\" in str(e):\n        time.sleep(backoff); backoff *= 2\n        continue  # retryable\n    raise  # 4xx (auth/404) are permanent","preventionTips":["Classify statuses: retry only 429/5xx; treat 401/403/404 as permanent","Store the prediction id immediately after submit so 404s on poll are diagnosable","Respect media size limits before upload to avoid 413"],"tags":["atlas-cloud","http","auth","rate-limit","network"],"backgroundTag":null,"analyzedSha":"95e1c3d0ab93482159818560f6a8c8e866b9139f","analyzedAt":"2026-08-15T06:31:20.014Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}