BerriAI/litellm · error · ValueError
MAVVRIK_API_KEY must be provided for Mavvrik FOCUS…
Error message
MAVVRIK_API_KEY must be provided for Mavvrik FOCUS destination (set MAVVRIK_API_KEY env var or pass in destination_config)
What it means
ValueError raised in FocusMavvrikDestination.__init__ when the resolved config has no truthy 'api_key'. The key is sent as the x-api-key header on every Mavvrik request. The factory resolves it from destination_config['api_key'] or the MAVVRIK_API_KEY env var, so this fires when neither is set. Fails fast at construction.
Solutions
- Set the env var: export MAVVRIK_API_KEY=<your-key>
- Or pass it explicitly: FocusMavvrikDestination(prefix='focus', config={'api_key': '<your-key>', 'api_endpoint': ..., 'connection_id': ...})
- In Kubernetes, verify the secret is mounted: kubectl exec -it deploy/proxy -- printenv MAVVRIK_API_KEY
Example fix
# before
FocusDestinationFactory.create(provider='mavvrik', prefix='focus', config={'api_endpoint': ep, 'connection_id': cid})
# after
export MAVVRIK_API_KEY=mk_live_xxx
FocusDestinationFactory.create(provider='mavvrik', prefix='focus', config={'api_endpoint': ep, 'connection_id': cid}) Defensive patterns
Strategy: validation
Validate before calling
import os
missing = [v for v in ("MAVVRIK_API_KEY", "MAVVRIK_API_ENDPOINT", "MAVVRIK_CONNECTION_ID") if not os.getenv(v)]
if missing:
raise SystemExit(f"Missing required Mavvrik env vars: {', '.join(missing)}") Type guard
import os
from typing import Any
def has_mavvrik_credentials(config: dict[str, Any] | None) -> bool:
"""True when all three Mavvrik credentials resolve from config or env."""
cfg = config or {}
return all(
cfg.get(k) or os.getenv(env)
for k, env in (
("api_key", "MAVVRIK_API_KEY"),
("api_endpoint", "MAVVRIK_API_ENDPOINT"),
("connection_id", "MAVVRIK_CONNECTION_ID"),
)
) Try / catch
try:
destination = FocusDestinationFactory.create(provider="mavvrik", prefix="focus", config=cfg)
except ValueError as e:
raise SystemExit(f"Mavvrik destination misconfigured: {e}") from e Prevention
- Set all three env vars (MAVVRIK_API_KEY, MAVVRIK_API_ENDPOINT, MAVVRIK_CONNECTION_ID) in the same secret/config unit so they deploy together
- Add a printenv smoke test to container startup
- Prefer config dict injection in code over scattered env vars for test determinism
When it happens
Trigger: Enabling the Mavvrik FOCUS destination (via FocusDestinationFactory.create(provider='mavvrik', ...) or direct construction) with MAVVRIK_API_KEY unset and no api_key in the config dict — e.g. empty string, or the key filtered out because it was None.
Common situations: Env var not exported in the cron/systemd/docker context running the proxy, Kubernetes secret not mounted or misnamed, CI pipeline missing the secret, key name typo (MAVVRIK_APIKEY).
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
- MAVVRIK_API_ENDPOINT must be an HTTPS URL
- MAVVRIK_API_ENDPOINT must be provided for Mavvrik FOCUS…
- MAVVRIK_CONNECTION_ID must be provided for Mavvrik FOCUS…
- MAVVRIK_API_ENDPOINT host must be a Mavvrik domain
- BFL_API_KEY is not set. Please set it via environment…
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/9a8c66704dfcba21.
Report an issue: GitHub.
Appendix: source
Thrown at litellm/integrations/focus/destinations/mavvrik_destination.py:67
)
class FocusMavvrikDestination(FocusDestination):
"""Upload FOCUS CSV exports to Mavvrik via GCS signed URL."""
def __init__(
self,
*,
prefix: str,
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("/")View on GitHub (pinned to 77b7c6c40c)