{"record":{"id":"5d021e11e98e40de","repo":"BerriAI/litellm","slug":"mavvrik-focus-destination-gcs-session-init-failed","errorCode":null,"errorMessage":"Mavvrik FOCUS destination: GCS session init failed ({init_resp.status_code}): {init_resp.text[:400]}","messagePattern":"Mavvrik FOCUS destination: GCS session init failed \\((.+?)\\): (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"litellm/integrations/focus/destinations/mavvrik_destination.py","lineNumber":189,"sourceCode":"        pipeline upstream).\n        \"\"\"\n        gzip_bytes: Final = gzip.compress(content)\n        total: Final = len(gzip_bytes)\n\n        # Step 1: initiate resumable upload session\n        metadata: Final = b'{\"contentEncoding\":\"gzip\",\"contentDisposition\":\"attachment\"}'\n        init_resp: Final = await self._http.client.request(\n            method=\"POST\",\n            url=signed_url,\n            headers={\n                \"Content-Type\": \"application/gzip\",\n                \"x-goog-resumable\": \"start\",\n            },\n            content=metadata,\n            timeout=30.0,\n        )\n        if init_resp.status_code not in (200, 201):\n            raise RuntimeError(\n                f\"Mavvrik FOCUS destination: GCS session init failed ({init_resp.status_code}): {init_resp.text[:400]}\"\n            )\n\n        session_uri: Final = init_resp.headers.get(\"Location\")\n        if not session_uri:\n            raise RuntimeError(\"Mavvrik FOCUS destination: GCS session init missing Location header\")\n        _validate_gcs_url(session_uri, \"session URI\")\n\n        verbose_logger.debug(\n            \"Mavvrik FOCUS destination: GCS session started, uploading %d gzip bytes in %d chunk(s)\",\n            total,\n            max(1, -(-total // _GCS_CHUNK_SIZE)),  # ceiling division\n        )\n\n        # Step 2: upload in chunks; cancel session on any failure to avoid\n        # lingering GCS sessions (they stay open for ~1 week otherwise).\n        offset = 0\n        try:","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/integrations/focus/destinations/mavvrik_destination.py#L171-L207","documentation":"RuntimeError raised when the resumable-upload session initiation — POST to the Mavvrik signed URL with header x-goog-resumable: start — returns a status other than 200/201. GCS should answer 201 with a Location session URI; failure here almost always means the signed URL is expired, malformed, or its signature does not match the request. The message includes the status and 400 chars of the GCS error body.","triggerScenarios":"deliver() fetches a signed URL, then immediately POSTs to start the session: 403 with 'invalid signature/expired token' when the URL's validity window elapsed (clock skew, queuing delay), 400 from bad request metadata, 429/5xx at init time.","commonSituations":"Host clock drift versus Google's signing window, long gaps between signed-URL fetch and upload (backpressure, event-loop starvation), Mavvrik issuing very short-lived URLs, or a truncated/mangled URL from env or proxy handling.","solutions":["Check the embedded GCS body: 403 mentioning expiry -> ensure NTP/clock sync on the host and retry the run (a fresh signed URL is fetched each deliver())","Persistent 403 'signature mismatch' -> report to Mavvrik; the URLs they sign are not matching the requests","429/5xx -> back off and let the next export cycle retry"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"import asyncio\n\nasync def deliver_with_retry(destination, *, content, time_window, filename, attempts=3):\n    for i in range(attempts):\n        try:\n            await destination.deliver(content=content, time_window=time_window, filename=filename)\n            return\n        except RuntimeError as e:\n            if \"GCS session init failed\" not in str(e):\n                raise\n            # A fresh deliver() fetches a new signed URL — retries usually heal expiry\n            if i < attempts - 1:\n                await asyncio.sleep(2**i)\n                continue\n            raise","preventionTips":["Keep host clocks NTP-synced; signed-URL validity windows are short","Avoid letting the event loop stall between starting an export and the upload","Retry the whole run rather than reusing a signed URL — each deliver() fetches a fresh one"],"tags":["mavvrik","gcs","signed-url","resumable-upload","expiry"],"backgroundTag":"signed-url-expired","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}