{"record":{"id":"c26831a2c74bcae0","repo":"BerriAI/litellm","slug":"mavvrik-focus-destination-failed-to-update-metric","errorCode":null,"errorMessage":"Mavvrik FOCUS destination: failed to update metricsMarker ({resp.status_code}): {resp.text[:200]}","messagePattern":"Mavvrik FOCUS destination: failed to update metricsMarker \\((.+?)\\): (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"litellm/integrations/focus/destinations/mavvrik_destination.py","lineNumber":262,"sourceCode":"            raise\n\n    async def _update_metrics_marker(self, date_epoch: int) -> None:\n        \"\"\"PATCH agent endpoint to advance metricsMarker after a successful upload.\"\"\"\n        resp: Final = await self._http.client.request(\n            method=\"PATCH\",\n            url=self._agent_url,\n            headers=self._auth_headers,\n            json={\"metricsMarker\": date_epoch},\n            timeout=30.0,\n        )\n        if resp.status_code == 410:\n            self._registered = False\n            raise RuntimeError(\n                \"Mavvrik FOCUS destination: connector is disconnected (410). \"\n                \"Re-enable the connection in the Mavvrik dashboard.\"\n            )\n        if resp.status_code >= 400:\n            raise RuntimeError(\n                f\"Mavvrik FOCUS destination: failed to update metricsMarker ({resp.status_code}): {resp.text[:200]}\"\n            )\n        verbose_logger.debug(\"Mavvrik FOCUS destination: metricsMarker advanced to %s\", date_epoch)\n\n    async def get_metrics_marker(self) -> int | None:\n        \"\"\"Register with Mavvrik and return the current metricsMarker.\n\n        Always calls the Mavvrik register API — unlike deliver() which skips\n        registration once _registered is True, catch-up requires a fresh\n        marker value on every run.\n        \"\"\"\n        resp: Final = await self._http.client.request(\n            method=\"POST\",\n            url=self._agent_url,\n            headers=self._auth_headers,\n            json={\"name\": self.connection_id},\n            timeout=30.0,\n        )","sourceCodeStart":244,"sourceCodeEnd":280,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/integrations/focus/destinations/mavvrik_destination.py#L244-L280","documentation":"RuntimeError raised when PATCH /metrics/agent/ai/{connection_id} with {'metricsMarker': date_epoch} returns any >=400 status (other than 410) after a successful GCS upload. The export data is safe in the bucket, but Mavvrik's catch-up watermark is not advanced, so subsequent runs may re-deliver that date. The message embeds the status and first 200 chars of the body.","triggerScenarios":"Transient 5xx at marker-update time immediately after an upload, 401/403 if the API key was revoked mid-session, or 400 if the PATCH body contract changed on Mavvrik's side.","commonSituations":"A Mavvrik blip right after upload completes, key rotation during a long backfill, API version drift between litellm and Mavvrik.","solutions":["Retry the export run — re-uploading the same date overwrites the same GCS object, so the retry is idempotent","401/403 -> refresh MAVVRIK_API_KEY before the next run","Persistent 400 -> upgrade litellm for an updated PATCH contract or report the body snippet to Mavvrik"],"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            if \"failed to update metricsMarker\" not in str(e):\n                raise\n            m = re.search(r\"\\((\\d+)\\)\", str(e))\n            status = int(m.group(1)) if m else 0\n            if i < attempts - 1 and (status >= 500 or status == 429):\n                await asyncio.sleep(2**i)\n                continue\n            raise","preventionTips":["Treat metricsMarker failures as retryable: the GCS object write is idempotent for the same date","Rotate MAVVRIK_API_KEY promptly when 401/403 appears in the embedded status","Monitor for repeated marker failures on the same date — it indicates a contract or auth problem, not transiency"],"tags":["mavvrik","metrics-marker","http-4xx","focus-export"],"backgroundTag":"api-update-rejected","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}