BerriAI/litellm · error · RuntimeError

Mavvrik FOCUS destination: failed to get signed URL

Error message

Mavvrik FOCUS destination: failed to get signed URL ({resp.status_code}): {resp.text[:200]}

What it means

RuntimeError raised in _get_signed_url when GET /metrics/agent/ai/{connection_id}/upload-url (query params name/type/datetime) returns >= 400 during deliver(). This call obtains the short-lived GCS signed URL that the gzip'd CSV is uploaded to; the message embeds the status and first 200 chars of the body.

Solutions

  1. Check the embedded status: 401/403 -> refresh MAVVRIK_API_KEY
  2. 429 -> reduce export frequency or shrink the backfill window, and retry
  3. 5xx -> retry the export run; missed dates are re-exported on the next successful run via the metricsMarker catch-up
Defensive patterns

Strategy: retry

Try / catch

import asyncio, re

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:
            msg = str(e)
            if "failed to get signed URL" not in msg:
                raise
            m = re.search(r"\((\d+)\)", msg)
            status = int(m.group(1)) if m else 0
            if i < attempts - 1 and (status == 429 or status >= 500):
                await asyncio.sleep(2**i)
                continue
            raise

Prevention

When it happens

Trigger: deliver() with an expired or revoked API key (401/403), a connection that no longer exists (404), rate limiting on the upload-url endpoint (429) during large catch-up backfills, or Mavvrik server errors (5xx) at signed-URL issuance time.

Common situations: Long-running proxy holding a stale key, aggressive export frequency hitting Mavvrik rate limits, transient Mavvrik incidents, mismatched connection_id.

Related errors


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

Appendix: source

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

        metrics_marker: Final = resp.json().get("metricsMarker", 0)
        verbose_logger.debug(
            "Mavvrik FOCUS destination: connector registered (metricsMarker=%s)",
            metrics_marker,
        )
        return metrics_marker

    async def _get_signed_url(self, date_str: str) -> str:
        """GET upload-url endpoint → GCS signed URL for the given date."""
        params: Final = {"name": date_str, "type": "metrics", "datetime": date_str}
        resp: Final = await self._http.client.request(
            method="GET",
            url=self._upload_url_endpoint,
            headers=self._auth_headers,
            params=params,
            timeout=30.0,
        )
        if resp.status_code >= 400:
            raise RuntimeError(
                f"Mavvrik FOCUS destination: failed to get signed URL ({resp.status_code}): {resp.text[:200]}"
            )
        signed_url: Final = resp.json().get("url")
        if not signed_url:
            raise RuntimeError(f"Mavvrik FOCUS destination: response missing 'url' field: {resp.json()}")
        _validate_gcs_url(signed_url, "signed URL")
        verbose_logger.debug("Mavvrik FOCUS destination: got signed URL for date %s", date_str)
        return signed_url

    async def _upload_to_gcs(self, signed_url: str, content: bytes) -> None:
        """Upload gzip-compressed CSV to GCS via chunked resumable upload.

        The full CSV is gzip-compressed first, then uploaded in _GCS_CHUNK_SIZE
        chunks using the GCS resumable upload protocol. GCS assembles the chunks
        server-side into a single complete object — the bucket receives one file
        regardless of how many chunks were sent.

        Intermediate chunks: Content-Range: bytes X-Y/*   → expect 308

View on GitHub (pinned to 77b7c6c40c)