BerriAI/litellm · error · ValueError
GCS_BUCKET_NAME is not set in the environment, but GCS…
Error message
GCS_BUCKET_NAME is not set in the environment, but GCS Bucket is being used as a logging callback. Please set 'GCS_BUCKET_NAME' in the environment.
What it means
Raised by the GCS logging base when building the logging config in dynamic mode: standard_callback_dynamic_params contained per-request overrides but no 'gcs_bucket_name', and the fallback attribute self.BUCKET_NAME (from the GCS_BUCKET_NAME env var) is also None. Dynamic mode is used when a request supplies callback_settings/dynamic parameters for GCS logging.
Solutions
- Set GCS_BUCKET_NAME in the proxy environment as the global fallback.
- Include gcs_bucket_name in the request's dynamic callback params when doing per-request GCS logging.
- Verify the env var is actually loaded by the process (docker-compose env, systemd Environment=, k8s secrets).
- Check the dynamic params dict for key typos — the exact key is 'gcs_bucket_name'.
Example fix
# before (dynamic params)
{"gcs_path_service_account": "/secrets/sa.json"} # no bucket -> ValueError
# after
{"gcs_bucket_name": "my-logs-bucket", "gcs_path_service_account": "/secrets/sa.json"} Defensive patterns
Strategy: validation
Validate before calling
import os
bucket = (dynamic_params or {}).get('gcs_bucket_name') or os.getenv('GCS_BUCKET_NAME')
if not bucket:
raise HTTPException(400, 'gcs_bucket_name (dynamic param) or GCS_BUCKET_NAME env var is required for GCS logging') Type guard
def gcs_bucket_resolved(dynamic_params: dict | None) -> bool:
return bool((dynamic_params or {}).get('gcs_bucket_name') or os.getenv('GCS_BUCKET_NAME')) Try / catch
try:
cfg = await logger._get_gcs_logging_config(dynamic_params)
except ValueError as e:
if 'GCS_BUCKET_NAME' in str(e):
return JSONResponse({'error': 'GCS bucket not configured'}, 400)
raise Prevention
- Set GCS_BUCKET_NAME globally even when per-request buckets are planned — it is the fallback.
- Validate dynamic callback params for the exact key 'gcs_bucket_name' before forwarding.
When it happens
Trigger: A request passes callback dynamic params like gcs_path_service_account but omits gcs_bucket_name while GCS_BUCKET_NAME is unset globally; the proxy-level callback was configured via dynamic params only; the env var was expected from a .env file the process never loaded.
Common situations: Per-tenant GCS logging where the bucket is meant to come from the request but the field name is mistyped; .env files not loaded in Docker/Compose; assuming the bucket from callback config YAML is used in dynamic mode when only the env var is consulted as fallback.
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
- endpoint not set for GenericAPILogger…
- FOCUS_GCS_BUCKET_NAME must be provided for GCS exports
- GCS Bucket logging is a premium feature. Please upgrade to…
- AZURE_SENTINEL_CLIENT_ID or AZURE_CLIENT_ID is required…
- AZURE_SENTINEL_CLIENT_SECRET or AZURE_CLIENT_SECRET is…
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/ef468c893308ee7b.
Report an issue: GitHub.
Appendix: source
Thrown at litellm/integrations/gcs_bucket/gcs_bucket_base.py:163
kwargs = {}
standard_callback_dynamic_params: Final[StandardCallbackDynamicParams | None] = kwargs.get(
"standard_callback_dynamic_params", None
)
bucket_name: str
path_service_account: str | None
if standard_callback_dynamic_params is not None:
verbose_logger.debug("Using dynamic GCS logging")
verbose_logger.debug("standard_callback_dynamic_params: %s", standard_callback_dynamic_params)
_bucket_name: str | None = standard_callback_dynamic_params.get("gcs_bucket_name", None) or self.BUCKET_NAME
_path_service_account: Final[str | None] = (
standard_callback_dynamic_params.get("gcs_path_service_account", None) or self.path_service_account_json
)
if _bucket_name is None:
raise ValueError(
"GCS_BUCKET_NAME is not set in the environment, but GCS Bucket is being used as a logging callback. Please set 'GCS_BUCKET_NAME' in the environment."
)
bucket_name = _bucket_name
path_service_account = _path_service_account
vertex_instance = await self.get_or_create_vertex_instance(credentials=path_service_account)
else:
# If no dynamic parameters, use the default instance
if self.BUCKET_NAME is None:
raise ValueError(
"GCS_BUCKET_NAME is not set in the environment, but GCS Bucket is being used as a logging callback. Please set 'GCS_BUCKET_NAME' in the environment."
)
bucket_name = self.BUCKET_NAME
path_service_account = self.path_service_account_json
vertex_instance = await self.get_or_create_vertex_instance(credentials=path_service_account)
return GCSLoggingConfig(
bucket_name=bucket_name,
vertex_instance=vertex_instance,View on GitHub (pinned to 77b7c6c40c)