BerriAI/litellm · error · ValueError

FOCUS_S3_BUCKET_NAME must be provided for S3 exports

Error message

FOCUS_S3_BUCKET_NAME must be provided for S3 exports

What it means

When building an S3 Focus destination, _resolve_config fills bucket_name from config overrides first, then the FOCUS_S3_BUCKET_NAME environment variable; if neither yields a value it raises ValueError. The bucket is the one piece of config with no default or inference (credentials can come from the standard AWS chain), so it is validated eagerly at factory time, not at first upload.

Solutions

  1. Set FOCUS_S3_BUCKET_NAME in the environment the export runs in
  2. Or pass bucket_name explicitly: FocusDestinationFactory.create(provider='s3', config={'bucket_name': ...})
  3. For containers/services, ensure the env var is declared in the unit/spec, not just the interactive shell
  4. Fail fast at startup: assert FOCUS_S3_BUCKET_NAME when S3 export is configured

Example fix

# before
dest = FocusDestinationFactory.create(provider='s3', prefix='focus/')

# after
import os
os.environ.setdefault('FOCUS_S3_BUCKET_NAME', 'my-focus-bucket')
dest = FocusDestinationFactory.create(
    provider='s3',
    prefix='focus/',
    config={'bucket_name': os.environ['FOCUS_S3_BUCKET_NAME']},
)
Defensive patterns

Strategy: validation

Validate before calling

import os

bucket = config.get('bucket_name') or os.getenv('FOCUS_S3_BUCKET_NAME')
if not bucket:
    raise ValueError('FOCUS_S3_BUCKET_NAME (or config bucket_name) required for S3 Focus export')
dest = FocusDestinationFactory.create(provider='s3', prefix='focus/', config={'bucket_name': bucket})

Try / catch

try:
    dest = FocusDestinationFactory.create(provider='s3', prefix='focus/', config=config)
except ValueError as e:
    if 'FOCUS_S3_BUCKET_NAME' in str(e):
        raise RuntimeError('S3 Focus export not configured; set FOCUS_S3_BUCKET_NAME') from e
    raise

Prevention

When it happens

Trigger: FocusDestinationFactory.create(provider='s3', ...) with no bucket_name in config and FOCUS_S3_BUCKET_NAME unset; env var set in the shell but not in the systemd/Docker service environment; a misspelled variable name (e.g. FOCUS_S3_BUCKET).

Common situations: Local works (env set in .bashrc), deployed worker fails (env not passed through); secrets managed per-environment and S3 region/keys set but bucket forgotten; k8s Secret not mounted into the export CronJob.

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/55aafdaefb32d586. Report an issue: GitHub.

Appendix: source

Thrown at litellm/integrations/focus/destinations/factory.py:54

        raise NotImplementedError(f"Provider '{provider}' not supported for Focus export")

    @staticmethod
    def _resolve_config(
        *,
        provider: str,
        overrides: dict[str, Any],
    ) -> dict[str, Any]:
        if provider == "s3":
            resolved = {
                "bucket_name": overrides.get("bucket_name") or os.getenv("FOCUS_S3_BUCKET_NAME"),
                "region_name": overrides.get("region_name") or os.getenv("FOCUS_S3_REGION_NAME"),
                "endpoint_url": overrides.get("endpoint_url") or os.getenv("FOCUS_S3_ENDPOINT_URL"),
                "aws_access_key_id": overrides.get("aws_access_key_id") or os.getenv("FOCUS_S3_ACCESS_KEY"),
                "aws_secret_access_key": overrides.get("aws_secret_access_key") or os.getenv("FOCUS_S3_SECRET_KEY"),
                "aws_session_token": overrides.get("aws_session_token") or os.getenv("FOCUS_S3_SESSION_TOKEN"),
            }
            if not resolved.get("bucket_name"):
                raise ValueError("FOCUS_S3_BUCKET_NAME must be provided for S3 exports")
            return {k: v for k, v in resolved.items() if v is not None}
        if provider == "vantage":
            resolved = {
                "api_key": overrides.get("api_key") or os.getenv("VANTAGE_API_KEY"),
                "integration_token": overrides.get("integration_token") or os.getenv("VANTAGE_INTEGRATION_TOKEN"),
                "base_url": overrides.get("base_url") or os.getenv("VANTAGE_BASE_URL", "https://api.vantage.sh"),
            }
            if not resolved.get("api_key"):
                raise ValueError("VANTAGE_API_KEY must be provided for Vantage exports")
            if not resolved.get("integration_token"):
                raise ValueError("VANTAGE_INTEGRATION_TOKEN must be provided for Vantage exports")
            return {k: v for k, v in resolved.items() if v is not None}
        if provider == "gcs":
            resolved = {
                "bucket_name": overrides.get("bucket_name") or os.getenv("FOCUS_GCS_BUCKET_NAME"),
                "service_account_json": overrides.get("service_account_json")
                or os.getenv("FOCUS_GCS_PATH_SERVICE_ACCOUNT"),
            }

View on GitHub (pinned to 77b7c6c40c)