BerriAI/litellm · error · ValueError

MAVVRIK_CONNECTION_ID must be provided for Mavvrik FOCUS…

Error message

MAVVRIK_CONNECTION_ID must be provided for Mavvrik FOCUS destination (set MAVVRIK_CONNECTION_ID env var or pass in destination_config)

What it means

ValueError raised in FocusMavvrikDestination.__init__ when the resolved config has no truthy 'connection_id'. The connection_id identifies the specific connector registered in the Mavvrik dashboard and is embedded in the API paths (/metrics/agent/ai/{connection_id}). Resolved from destination_config['connection_id'] or MAVVRIK_CONNECTION_ID; last of the three construction-time checks.

Solutions

  1. Copy the connector ID from the Mavvrik dashboard and set export MAVVRIK_CONNECTION_ID=<id>
  2. Or pass it in config: config={'connection_id': '<id>', ...}
  3. Trim stray whitespace/quotes when pasting into dotfiles or container env blocks

Example fix

# before
export MAVVRIK_API_KEY=mk_live_xxx
export MAVVRIK_API_ENDPOINT=https://api.mavvrik.dev/acme
# MAVVRIK_CONNECTION_ID missing

# after
export MAVVRIK_CONNECTION_ID=conn_7f3a2b
Defensive patterns

Strategy: validation

Validate before calling

import os

connection_id = (config or {}).get("connection_id") or os.getenv("MAVVRIK_CONNECTION_ID")
if not connection_id:
    raise SystemExit("MAVVRIK_CONNECTION_ID is required (env var or destination_config['connection_id'])")

Type guard

import os
from typing import Any

def has_mavvrik_connection_id(config: dict[str, Any] | None) -> bool:
    """True when a Mavvrik connector id is resolvable."""
    return bool((config or {}).get("connection_id") or os.getenv("MAVVRIK_CONNECTION_ID"))

Try / catch

try:
    destination = FocusMavvrikDestination(prefix="focus", config=cfg)
except ValueError as e:
    raise SystemExit(f"Mavvrik destination misconfigured: {e}") from e

Prevention

When it happens

Trigger: Enabling the Mavvrik FOCUS destination with MAVVRIK_CONNECTION_ID unset and no connection_id in the config dict, while api_key and api_endpoint are present.

Common situations: The connection was created in the Mavvrik UI but its ID never copied into the deployment env; the ID was copied with whitespace; a re-created connector got a new ID that was never propagated.

Understand the failure class

Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.

Related errors


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

Appendix: source

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

        config: dict[str, Any] | None = None,
    ) -> None:
        config = config or {}
        api_key: Final = config.get("api_key")
        api_endpoint: Final = config.get("api_endpoint")
        connection_id: Final = config.get("connection_id")

        if not api_key:
            raise ValueError(
                "MAVVRIK_API_KEY must be provided for Mavvrik FOCUS destination "
                "(set MAVVRIK_API_KEY env var or pass in destination_config)"
            )
        if not api_endpoint:
            raise ValueError(
                "MAVVRIK_API_ENDPOINT must be provided for Mavvrik FOCUS destination "
                "(set MAVVRIK_API_ENDPOINT env var or pass in destination_config)"
            )
        if not connection_id:
            raise ValueError(
                "MAVVRIK_CONNECTION_ID must be provided for Mavvrik FOCUS destination "
                "(set MAVVRIK_CONNECTION_ID env var or pass in destination_config)"
            )

        _validate_api_endpoint(api_endpoint)

        self.api_key = api_key
        self.api_endpoint = api_endpoint.rstrip("/")
        self.connection_id = connection_id
        self.prefix = prefix
        self._http: AsyncHTTPHandler = get_async_httpx_client(llm_provider=httpxSpecialProvider.LoggingCallback)
        self._registered = False

    @property
    def _agent_url(self) -> str:
        return f"{self.api_endpoint}/metrics/agent/ai/{self.connection_id}"

    @property

View on GitHub (pinned to 77b7c6c40c)