BerriAI/litellm · error · ImportError

Failed to download {object_key} from {storage_type} bucket {

Error message

Failed to download {object_key} from {storage_type} bucket {bucket_name}

What it means

The S3 or GCS download helper returned falsy for the given object key, meaning the file could not be fetched from the bucket (missing object, permissions, or client misconfiguration) even though the URL was structurally valid. Raised as ImportError since the module code is unavailable.

Source

Thrown at litellm/proxy/types_utils/utils.py:159

        local_file_path: Final = temp_file.name
        temp_file.close()  # Close the file so we can write to it

        # Download the file
        if storage_type == "s3":
            from litellm.proxy.common_utils.load_config_utils import (
                download_python_file_from_s3,
            )

            success = download_python_file_from_s3(
                bucket_name=bucket_name,
                object_key=object_key,
                local_file_path=local_file_path,
            )
        else:  # gcs
            success = asyncio.run(_download_gcs_file_wrapper(bucket_name, object_key, local_file_path))

        if not success:
            raise ImportError(f"Failed to download {object_key} from {storage_type} bucket {bucket_name}")

        # Load the module from the downloaded file using the actual module name
        spec: Final = importlib.util.spec_from_file_location(module_path, local_file_path)
        if spec is None or spec.loader is None:
            raise ImportError(f"Could not create module spec for {local_file_path}")

        module: Final = importlib.util.module_from_spec(spec)
        spec.loader.exec_module(module)

        # Get the instance
        instance: Final = getattr(module, instance_name)

        # Clean up the temporary file
        try:
            os.remove(local_file_path)
        except Exception as cleanup_error:
            verbose_proxy_logger.warning("Could not clean up temporary file %s: %s", local_file_path, cleanup_error)

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Check cloud credentials and bucket/object permissions, and verify the object key exists in the bucket.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/proxy/types_utils/utils.py:159 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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