BerriAI/litellm · error · RuntimeError
Mavvrik FOCUS destination: GCS session init failed
Error message
Mavvrik FOCUS destination: GCS session init failed ({init_resp.status_code}): {init_resp.text[:400]} What it means
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.
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
Defensive patterns
Strategy: retry
Try / catch
import asyncio
async def deliver_with_retry(destination, *, content, time_window, filename, attempts=3):
for i in range(attempts):
try:
await destination.deliver(content=content, time_window=time_window, filename=filename)
return
except RuntimeError as e:
if "GCS session init failed" not in str(e):
raise
# A fresh deliver() fetches a new signed URL — retries usually heal expiry
if i < attempts - 1:
await asyncio.sleep(2**i)
continue
raise Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Mavvrik FOCUS destination: GCS chunk upload failed
- Mavvrik FOCUS destination: failed to get signed URL
- Mavvrik FOCUS destination: GCS session init missing…
- Mavvrik FOCUS destination
- Mavvrik FOCUS destination
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/5d021e11e98e40de.
Report an issue: GitHub.
Appendix: source
Thrown at litellm/integrations/focus/destinations/mavvrik_destination.py:189
pipeline upstream).
"""
gzip_bytes: Final = gzip.compress(content)
total: Final = len(gzip_bytes)
# Step 1: initiate resumable upload session
metadata: Final = b'{"contentEncoding":"gzip","contentDisposition":"attachment"}'
init_resp: Final = await self._http.client.request(
method="POST",
url=signed_url,
headers={
"Content-Type": "application/gzip",
"x-goog-resumable": "start",
},
content=metadata,
timeout=30.0,
)
if init_resp.status_code not in (200, 201):
raise RuntimeError(
f"Mavvrik FOCUS destination: GCS session init failed ({init_resp.status_code}): {init_resp.text[:400]}"
)
session_uri: Final = init_resp.headers.get("Location")
if not session_uri:
raise RuntimeError("Mavvrik FOCUS destination: GCS session init missing Location header")
_validate_gcs_url(session_uri, "session URI")
verbose_logger.debug(
"Mavvrik FOCUS destination: GCS session started, uploading %d gzip bytes in %d chunk(s)",
total,
max(1, -(-total // _GCS_CHUNK_SIZE)), # ceiling division
)
# Step 2: upload in chunks; cancel session on any failure to avoid
# lingering GCS sessions (they stay open for ~1 week otherwise).
offset = 0
try:View on GitHub (pinned to 77b7c6c40c)