{"record":{"id":"f721d0c3827d0aab","repo":"BerriAI/litellm","slug":"mavvrik-focus-destination-register-failed-resp","errorCode":null,"errorMessage":"Mavvrik FOCUS destination: register failed ({resp.status_code}): {resp.text[:200]}","messagePattern":"Mavvrik FOCUS destination: register failed \\((.+?)\\): (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"litellm/integrations/focus/destinations/mavvrik_destination.py","lineNumber":128,"sourceCode":"        Returns None if the connector was already registered (cached).\n        \"\"\"\n        if self._registered:\n            return None\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        )\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(f\"Mavvrik FOCUS destination: register failed ({resp.status_code}): {resp.text[:200]}\")\n        self._registered = True\n        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        )","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/integrations/focus/destinations/mavvrik_destination.py#L110-L146","documentation":"RuntimeError wrapping any >=400 response other than 410 from POST /metrics/agent/ai/{connection_id} during registration at the start of deliver(). Registration initializes the connector and returns the metricsMarker used for catch-up; the message embeds the status code and first 200 characters of the Mavvrik response body for diagnosis.","triggerScenarios":"401/403 when MAVVRIK_API_KEY is invalid, expired, or revoked; 404 when connection_id is wrong or the tenant path in api_endpoint does not match; 429/5xx during Mavvrik rate limiting or an outage — each at the first deliver() call of an export run.","commonSituations":"Rotated API keys not updated in the deployment, a connection_id typo, the tenant segment missing from MAVVRIK_API_ENDPOINT (wrong URL → 404), or a Mavvrik-side incident.","solutions":["Read the embedded status: 401/403 -> generate a fresh API key in Mavvrik and update MAVVRIK_API_KEY","404 -> verify MAVVRIK_CONNECTION_ID exists and api_endpoint includes the tenant path (https://api.mavvrik.dev/<tenant_id>)","5xx -> retry on the next export cycle; the FOCUS logger backfills missed dates"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"async def mavvrik_register_ok(api_endpoint: str, api_key: str, connection_id: str) -> tuple[bool, str]:\n    \"\"\"Probe registration; returns (ok, body) for the caller to branch on.\"\"\"\n    resp = await httpx.AsyncClient().request(\n        method=\"POST\",\n        url=f\"{api_endpoint}/metrics/agent/ai/{connection_id}\",\n        headers={\"Content-Type\": \"application/json\", \"x-api-key\": api_key},\n        json={\"name\": connection_id},\n        timeout=30.0,\n    )\n    return resp.status_code < 400, resp.text[:200]","typeGuard":null,"tryCatchPattern":"try:\n    await destination.deliver(content=content, time_window=tw, filename=fn)\nexcept RuntimeError as e:\n    msg = str(e)\n    if \"register failed (401)\" in msg or \"register failed (403)\" in msg:\n        rotate_mavvrik_api_key()  # permanent auth failure\n        raise\n    if \"register failed (5\" in msg or \"register failed (429)\" in msg:\n        schedule_retry(backoff=\"next_cycle\")  # transient\n        return\n    raise","preventionTips":["Parse the embedded status code from the message to branch: 4xx-credentials -> fix config, 5xx/429 -> retry","Keep API keys in a rotation workflow so revocations update the env quickly","Verify connection_id and tenant path whenever registration starts failing suddenly"],"tags":["mavvrik","http-4xx","registration","auth","focus-export"],"backgroundTag":"invalid-api-key","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}