{"record":{"id":"540448e3b6aad836","repo":"BerriAI/litellm","slug":"mavvrik-focus-destination-failed-to-get-signed-ur","errorCode":null,"errorMessage":"Mavvrik FOCUS destination: failed to get signed URL ({resp.status_code}): {resp.text[:200]}","messagePattern":"Mavvrik FOCUS destination: failed to get signed URL \\((.+?)\\): (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"litellm/integrations/focus/destinations/mavvrik_destination.py","lineNumber":148,"sourceCode":"        metrics_marker: Final = resp.json().get(\"metricsMarker\", 0)\n        verbose_logger.debug(\n            \"Mavvrik FOCUS destination: connector registered (metricsMarker=%s)\",\n            metrics_marker,\n        )\n        return metrics_marker\n\n    async def _get_signed_url(self, date_str: str) -> str:\n        \"\"\"GET upload-url endpoint → GCS signed URL for the given date.\"\"\"\n        params: Final = {\"name\": date_str, \"type\": \"metrics\", \"datetime\": date_str}\n        resp: Final = await self._http.client.request(\n            method=\"GET\",\n            url=self._upload_url_endpoint,\n            headers=self._auth_headers,\n            params=params,\n            timeout=30.0,\n        )\n        if resp.status_code >= 400:\n            raise RuntimeError(\n                f\"Mavvrik FOCUS destination: failed to get signed URL ({resp.status_code}): {resp.text[:200]}\"\n            )\n        signed_url: Final = resp.json().get(\"url\")\n        if not signed_url:\n            raise RuntimeError(f\"Mavvrik FOCUS destination: response missing 'url' field: {resp.json()}\")\n        _validate_gcs_url(signed_url, \"signed URL\")\n        verbose_logger.debug(\"Mavvrik FOCUS destination: got signed URL for date %s\", date_str)\n        return signed_url\n\n    async def _upload_to_gcs(self, signed_url: str, content: bytes) -> None:\n        \"\"\"Upload gzip-compressed CSV to GCS via chunked resumable upload.\n\n        The full CSV is gzip-compressed first, then uploaded in _GCS_CHUNK_SIZE\n        chunks using the GCS resumable upload protocol. GCS assembles the chunks\n        server-side into a single complete object — the bucket receives one file\n        regardless of how many chunks were sent.\n\n        Intermediate chunks: Content-Range: bytes X-Y/*   → expect 308","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/integrations/focus/destinations/mavvrik_destination.py#L130-L166","documentation":"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.","triggerScenarios":"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.","commonSituations":"Long-running proxy holding a stale key, aggressive export frequency hitting Mavvrik rate limits, transient Mavvrik incidents, mismatched connection_id.","solutions":["Check the embedded status: 401/403 -> refresh MAVVRIK_API_KEY","429 -> reduce export frequency or shrink the backfill window, and retry","5xx -> retry the export run; missed dates are re-exported on the next successful run via the metricsMarker catch-up"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"import asyncio, re\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            msg = str(e)\n            if \"failed to get signed URL\" not in msg:\n                raise\n            m = re.search(r\"\\((\\d+)\\)\", msg)\n            status = int(m.group(1)) if m else 0\n            if i < attempts - 1 and (status == 429 or status >= 500):\n                await asyncio.sleep(2**i)\n                continue\n            raise","preventionTips":["Retry only 429/5xx with exponential backoff; 401/403 need a key rotation, 404 needs a config fix","Cap export frequency and backfill batch size to stay under Mavvrik rate limits","Rely on the metricsMarker catch-up to heal gaps after transient failures"],"tags":["mavvrik","signed-url","http-4xx","focus-export"],"backgroundTag":"presigned-url-fetch-failed","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}