BerriAI/litellm · error · ValueError

Failed to download file from S3

Error message

Failed to download file from S3: {s3_uri}. Error: {e}

What it means

Error-mapping wrapper around the S3 GetObject call in file download: after successfully parsing the s3:// URI and creating the client, s3_client.get_object raised (missing object, permissions, region issues), and the error is re-raised with the URI and cause for diagnostics.

Solutions

  1. Verify the S3 URI is correct and the object exists.
  2. Check IAM permissions allow s3:GetObject on the bucket.
  3. Check network/credentials used for the S3 download.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at litellm/llms/bedrock/files/handler.py:133 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/12994785a9c48d5b. Report an issue: GitHub.

Appendix: source

Thrown at litellm/llms/bedrock/files/handler.py:133

            aws_sts_endpoint=optional_params.get("aws_sts_endpoint"),
        )

        # Create S3 client
        s3_client: Final = boto3.client(
            "s3",
            aws_access_key_id=credentials.access_key,
            aws_secret_access_key=credentials.secret_key,
            aws_session_token=credentials.token,
            region_name=aws_region_name,
            verify=self._get_ssl_verify(),
        )

        # Download file from S3
        try:
            response: Final = s3_client.get_object(Bucket=bucket_name, Key=object_key)
            file_content: Final = response["Body"].read()
        except Exception as e:
            raise ValueError(f"Failed to download file from S3: {s3_uri}. Error: {e}")

        # Create mock HTTP response
        mock_response: Final = httpx.Response(
            status_code=200,
            content=file_content,
            headers={"content-type": "application/octet-stream"},
            request=httpx.Request(method="GET", url=s3_uri),
        )

        return HttpxBinaryResponseContent(response=mock_response)

    def file_content(
        self,
        _is_async: bool,
        file_content_request: FileContentRequest,
        api_base: str | None,
        optional_params: dict,
        timeout: float | httpx.Timeout,

View on GitHub (pinned to 77b7c6c40c)