{"record":{"id":"ef468c893308ee7b","repo":"BerriAI/litellm","slug":"gcs-bucket-name-is-not-set-in-the-environment-but","errorCode":null,"errorMessage":"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.","messagePattern":"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\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/integrations/gcs_bucket/gcs_bucket_base.py","lineNumber":163,"sourceCode":"            kwargs = {}\n\n        standard_callback_dynamic_params: Final[StandardCallbackDynamicParams | None] = kwargs.get(\n            \"standard_callback_dynamic_params\", None\n        )\n\n        bucket_name: str\n        path_service_account: str | None\n        if standard_callback_dynamic_params is not None:\n            verbose_logger.debug(\"Using dynamic GCS logging\")\n            verbose_logger.debug(\"standard_callback_dynamic_params: %s\", standard_callback_dynamic_params)\n\n            _bucket_name: str | None = standard_callback_dynamic_params.get(\"gcs_bucket_name\", None) or self.BUCKET_NAME\n            _path_service_account: Final[str | None] = (\n                standard_callback_dynamic_params.get(\"gcs_path_service_account\", None) or self.path_service_account_json\n            )\n\n            if _bucket_name is None:\n                raise ValueError(\n                    \"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.\"\n                )\n            bucket_name = _bucket_name\n            path_service_account = _path_service_account\n            vertex_instance = await self.get_or_create_vertex_instance(credentials=path_service_account)\n        else:\n            # If no dynamic parameters, use the default instance\n            if self.BUCKET_NAME is None:\n                raise ValueError(\n                    \"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.\"\n                )\n            bucket_name = self.BUCKET_NAME\n            path_service_account = self.path_service_account_json\n            vertex_instance = await self.get_or_create_vertex_instance(credentials=path_service_account)\n\n        return GCSLoggingConfig(\n            bucket_name=bucket_name,\n            vertex_instance=vertex_instance,","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/integrations/gcs_bucket/gcs_bucket_base.py#L145-L181","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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'."],"exampleFix":"# before (dynamic params)\n{\"gcs_path_service_account\": \"/secrets/sa.json\"}  # no bucket -> ValueError\n\n# after\n{\"gcs_bucket_name\": \"my-logs-bucket\", \"gcs_path_service_account\": \"/secrets/sa.json\"}","handlingStrategy":"validation","validationCode":"import os\n\nbucket = (dynamic_params or {}).get('gcs_bucket_name') or os.getenv('GCS_BUCKET_NAME')\nif not bucket:\n    raise HTTPException(400, 'gcs_bucket_name (dynamic param) or GCS_BUCKET_NAME env var is required for GCS logging')","typeGuard":"def gcs_bucket_resolved(dynamic_params: dict | None) -> bool:\n    return bool((dynamic_params or {}).get('gcs_bucket_name') or os.getenv('GCS_BUCKET_NAME'))","tryCatchPattern":"try:\n    cfg = await logger._get_gcs_logging_config(dynamic_params)\nexcept ValueError as e:\n    if 'GCS_BUCKET_NAME' in str(e):\n        return JSONResponse({'error': 'GCS bucket not configured'}, 400)\n    raise","preventionTips":["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."],"tags":["gcs","logging-callback","missing-env-var","dynamic-config"],"backgroundTag":"missing-env-var","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}