BerriAI/litellm · error · ValueError

MAVVRIK_API_ENDPOINT must be an HTTPS URL

Error message

MAVVRIK_API_ENDPOINT must be an HTTPS URL

What it means

ValueError from _validate_api_endpoint when MAVVRIK_API_ENDPOINT (config key 'api_endpoint') does not start with https://. Every Mavvrik call sends the credential in the x-api-key header, so the destination refuses to authenticate over plaintext. Raised at construction time, before any network traffic.

Solutions

  1. Set the full HTTPS endpoint: export MAVVRIK_API_ENDPOINT=https://api.mavvrik.dev/<tenant_id>
  2. Or pass it in config: FocusMavvrikDestination(prefix='focus', config={'api_endpoint': 'https://api.mavvrik.dev/<tenant_id>', ...})
  3. Strip surrounding quotes/whitespace from the env var in container definitions

Example fix

# before
MAVVRIK_API_ENDPOINT=http://api.mavvrik.dev/acme

# after
MAVVRIK_API_ENDPOINT=https://api.mavvrik.dev/acme
Defensive patterns

Strategy: validation

Validate before calling

import os

endpoint = os.getenv("MAVVRIK_API_ENDPOINT") or (config or {}).get("api_endpoint") or ""
if not endpoint.startswith("https://"):
    raise SystemExit(f"MAVVRIK_API_ENDPOINT must start with https://, got: {endpoint!r}")

Type guard

def is_https_mavvrik_endpoint(endpoint: str) -> bool:
    """True when the endpoint passes litellm's scheme + host checks."""
    from urllib.parse import urlparse
    if not endpoint.startswith("https://"):
        return False
    host = (urlparse(endpoint).hostname or "").lower()
    return any(host.endswith(s) for s in (".mavvrik.dev", ".mavvrik.ai", ".mavvrik.app"))

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: Constructing FocusMavvrikDestination (directly or via FocusDestinationFactory.create(provider='mavvrik', ...)) with api_endpoint='http://api.mavvrik.dev/tenant' or 'api.mavvrik.dev/tenant' (no scheme), typically from the MAVVRIK_API_ENDPOINT env var or destination_config.

Common situations: Endpoint copied without the scheme, local testing against http://localhost, quotes or trailing whitespace baked into the env var by docker-compose/Kubernetes secret wrappers.

Related errors


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

Appendix: source

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

from litellm._logging import verbose_logger
from litellm.llms.custom_httpx.http_handler import (
    AsyncHTTPHandler,
    get_async_httpx_client,
    httpxSpecialProvider,
)

from .base import FocusDestination, FocusTimeWindow

_MAVVRIK_ALLOWED_SUFFIXES: Final = (".mavvrik.dev", ".mavvrik.ai", ".mavvrik.app")

# GCS requires intermediate chunks to be a multiple of 256 KB.
# 8 MB gives a good balance between round-trips and memory pressure.
_GCS_CHUNK_SIZE: Final = 8 * 1024 * 1024  # 8 MB


def _validate_api_endpoint(api_endpoint: str) -> None:
    if not api_endpoint.startswith("https://"):
        raise ValueError("MAVVRIK_API_ENDPOINT must be an HTTPS URL")
    hostname: Final = (urlparse(api_endpoint).hostname or "").lower()
    if not any(hostname.endswith(suffix) for suffix in _MAVVRIK_ALLOWED_SUFFIXES):
        raise ValueError(
            "MAVVRIK_API_ENDPOINT host must be a Mavvrik domain (e.g. https://api.mavvrik.dev/<tenant_id>)"
        )


def _validate_gcs_url(url: str, label: str) -> None:
    parsed: Final = urlparse(url)
    if parsed.scheme != "https":
        raise ValueError(f"Mavvrik FOCUS destination: {label} must be HTTPS, got scheme '{parsed.scheme}'")
    hostname: Final = (parsed.hostname or "").lower()
    if not (hostname == "storage.googleapis.com" or hostname.endswith(".storage.googleapis.com")):
        raise ValueError(
            f"Mavvrik FOCUS destination: {label} must be a GCS endpoint (storage.googleapis.com), got '{hostname}'"
        )

View on GitHub (pinned to 77b7c6c40c)