BerriAI/litellm · error · RuntimeError

Mavvrik FOCUS destination: GCS session init missing…

Error message

Mavvrik FOCUS destination: GCS session init missing Location header

What it means

RuntimeError raised when GCS answers the resumable-session init with 200/201 but the response carries no Location header. The Location header holds the session URI used for every subsequent chunk PUT; without it the resumable protocol cannot proceed. Extremely rare against real GCS — usually an intermediary on the network path strips or renames the header.

Solutions

  1. Reproduce outside the proxy (curl -i on a session-init request) to confirm the header is stripped in transit
  2. Configure the proxy/gateway to pass the Location response header through unmodified
  3. If it reproduces with a direct connection, gather the response headers and report to Mavvrik/litellm maintainers
Defensive patterns

Strategy: try-catch

Try / catch

try:
    await destination.deliver(content=content, time_window=tw, filename=fn)
except RuntimeError as e:
    if "missing Location header" in str(e):
        logger.error("Network path strips the GCS Location header; check egress proxy config: %s", e)
        raise
    raise

Prevention

When it happens

Trigger: A corporate proxy, API gateway, or service mesh between litellm and storage.googleapis.com removes the Location header on the init response; the destination then aborts before uploading any chunks.

Common situations: Egress proxies with header allowlists, misconfigured Envoy/NGINX intermediaries, TLS-inspecting middleboxes, or security appliances rewriting redirect-style headers.

Related errors


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/38f0d4e391f9462d. Report an issue: GitHub.

Appendix: source

Thrown at litellm/integrations/focus/destinations/mavvrik_destination.py:195

        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:
            while offset < total:
                chunk = gzip_bytes[offset : offset + _GCS_CHUNK_SIZE]
                chunk_end = offset + len(chunk) - 1
                is_final = (offset + len(chunk)) >= total
                content_range = f"bytes {offset}-{chunk_end}/{total}" if is_final else f"bytes {offset}-{chunk_end}/*"
                expected_statuses = {200, 201} if is_final else {308}

View on GitHub (pinned to 77b7c6c40c)