{"record":{"id":"1a42980beadc2273","repo":"calesthio/OpenMontage","slug":"uploading-path-name-to-atlas-cloud-failed-exc","errorCode":null,"errorMessage":"Uploading {path.name} to Atlas Cloud failed: {exc}","messagePattern":"Uploading (.+?) to Atlas Cloud failed: (.+?)","errorType":"exception","errorClass":"AtlasError","httpStatus":null,"severity":"error","filePath":"tools/atlas_client.py","lineNumber":209,"sourceCode":"    models expect. Atlas has answered this endpoint with both {\"data\":\n    {\"download_url\": ...}} and a bare {\"url\": ...}, so both shapes are accepted.\n    \"\"\"\n    import requests\n\n    path = Path(file_path)\n    if not path.exists():\n        raise AtlasError(f\"Cannot upload — file not found: {path}\")\n\n    try:\n        with path.open(\"rb\") as handle:\n            response = requests.post(\n                UPLOAD_MEDIA_ENDPOINT,\n                headers=_headers(api_key, json_body=False),\n                files={\"file\": (path.name, handle)},\n                timeout=timeout,\n            )\n    except Exception as exc:  # noqa: BLE001\n        raise AtlasError(f\"Uploading {path.name} to Atlas Cloud failed: {exc}\") from exc\n\n    _raise_for_status(response, \"Atlas Cloud upload\")\n    data = _payload_of(response)\n\n    url = data.get(\"download_url\") or data.get(\"url\")\n    if not url:\n        raise AtlasError(f\"Atlas Cloud upload returned no URL: {str(data)[:500]}\")\n    return str(url)\n\n\ndef download(url: str, output_path: str | Path, timeout: int = 300) -> Path:\n    \"\"\"Download a generated asset to disk and return the written path.\"\"\"\n    import requests\n\n    try:\n        response = requests.get(url, timeout=timeout)\n    except Exception as exc:  # noqa: BLE001\n        raise AtlasError(f\"Downloading Atlas Cloud output failed: {exc}\") from exc","sourceCodeStart":191,"sourceCodeEnd":227,"githubUrl":"https://github.com/calesthio/OpenMontage/blob/95e1c3d0ab93482159818560f6a8c8e866b9139f/tools/atlas_client.py#L191-L227","documentation":"Raised by upload_media when the multipart POST to the Atlas upload endpoint throws any exception — connection failure, TLS error, or requests timeout (default 120s). Opening the file locally has already succeeded; the failure is purely in transit or at the server's front door. The exception is chained for full detail.","triggerScenarios":"Uploading a large video over a slow link exceeding the 120s default timeout; connection reset by the server due to body-size limits enforced at the TCP/proxy layer; DNS/TLS failures reaching the upload host; proxy rejection of multipart content.","commonSituations":"Reference videos in the hundreds of MB with default timeout; mobile or constrained uplinks; corporate proxies blocking large POST bodies; transient cloud-front blips during upload.","solutions":["If the message mentions timeout, raise the timeout argument proportional to file size and bandwidth","Compress or resize the media before upload (smaller dimensions/CRF) to shrink transfer time","Retry once — transient resets are common for large uploads","Verify egress to the upload endpoint and bypass restrictive proxies"],"exampleFix":"// before\nurl = atlas_client.upload_media(path, api_key)\n\n// after\nurl = atlas_client.upload_media(path, api_key, timeout=600)","handlingStrategy":"retry","validationCode":"size_mb = path.stat().st_size / (1024 * 1024)\ntimeout = max(120, int(size_mb * 4))  # ~4s/MB heuristic for slow links","typeGuard":null,"tryCatchPattern":"for attempt in range(2):\n    try:\n        url = atlas_client.upload_media(path, api_key, timeout=timeout)\n        break\n    except AtlasError as e:\n        if \"Uploading\" not in str(e) or attempt == 1:\n            raise\n        time.sleep(10)","preventionTips":["Compress/resize reference media before upload","Scale the timeout argument to file size and your uplink bandwidth","Retry large uploads once before investigating — transient resets are the common case"],"tags":["atlas-cloud","upload","network","timeout","large-files"],"backgroundTag":null,"analyzedSha":"95e1c3d0ab93482159818560f6a8c8e866b9139f","analyzedAt":"2026-08-15T06:31:20.014Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}