BerriAI/litellm · error · ValueError

FOCUS_GCS_BUCKET_NAME must be provided for GCS exports

Error message

FOCUS_GCS_BUCKET_NAME must be provided for GCS exports

What it means

When building a GCS Focus destination, _resolve_config resolves bucket_name from config overrides then the FOCUS_GCS_BUCKET_NAME environment variable and raises ValueError if neither is set. The optional service account (service_account_json override or FOCUS_GCS_PATH_SERVICE_ACCOUNT env) is not required here — only the bucket is validated eagerly; credential problems surface later at upload time.

Solutions

  1. Set FOCUS_GCS_BUCKET_NAME to the target bucket (no gs:// scheme needed)
  2. Or pass bucket_name in the config dict to create()
  3. Optionally set FOCUS_GCS_PATH_SERVICE_ACCOUNT for the service-account JSON when not using Application Default Credentials
  4. Declare the env var in the container/service spec for the export job

Example fix

# before
os.environ['FOCUS_GCS_PATH_SERVICE_ACCOUNT'] = '/secrets/gcp.json'  # credentials only
dest = FocusDestinationFactory.create(provider='gcs', prefix='focus/')

# after
os.environ['FOCUS_GCS_BUCKET_NAME'] = 'my-focus-bucket'
os.environ['FOCUS_GCS_PATH_SERVICE_ACCOUNT'] = '/secrets/gcp.json'
dest = FocusDestinationFactory.create(provider='gcs', prefix='focus/')
Defensive patterns

Strategy: validation

Validate before calling

import os

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

Try / catch

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

Prevention

When it happens

Trigger: FocusDestinationFactory.create(provider='gcs', ...) with no bucket_name in config and FOCUS_GCS_BUCKET_NAME unset; confusing FOCUS_GCS_PATH_SERVICE_ACCOUNT (credentials) with the bucket variable and setting only the former; env var missing in the deployed worker.

Common situations: GCP deployments where the bucket name lives in Terraform but was never exported as env; naming confusion between the S3-style FOCUS_S3_BUCKET_NAME and the GCS variable; local env set, container env not.

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

Appendix: source

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

        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"),
            }
            if not resolved.get("bucket_name"):
                raise ValueError("FOCUS_GCS_BUCKET_NAME must be provided for GCS exports")
            return {k: v for k, v in resolved.items() if v is not None}
        if provider == "mavvrik":
            resolved = {
                "api_key": overrides.get("api_key") or os.getenv("MAVVRIK_API_KEY"),
                "api_endpoint": overrides.get("api_endpoint") or os.getenv("MAVVRIK_API_ENDPOINT"),
                "connection_id": overrides.get("connection_id") or os.getenv("MAVVRIK_CONNECTION_ID"),
            }
            return {k: v for k, v in resolved.items() if v is not None}
        raise NotImplementedError(f"Provider '{provider}' not supported for Focus export configuration")

View on GitHub (pinned to 77b7c6c40c)