BerriAI/litellm · error · ValueError
file_id is required in file_content_request
Error message
file_id is required in file_content_request
What it means
BedrockFilesHandler.file_content() requires the OpenAI-style file content request to contain file_id, which encodes the S3 location of the managed file. The guard rejects empty/missing file_id before any S3 interaction happens.
Source
Thrown at litellm/llms/bedrock/files/handler.py:93
) -> HttpxBinaryResponseContent:
"""
Download file content from S3 bucket for Bedrock files.
Args:
file_content_request: Contains file_id (encoded or S3 URI)
optional_params: Optional parameters containing AWS credentials
timeout: Request timeout
max_retries: Max retry attempts
Returns:
HttpxBinaryResponseContent: Binary content wrapped in compatible response format
"""
import boto3
from botocore.credentials import Credentials
file_id: Final = file_content_request.get("file_id")
if not file_id:
raise ValueError("file_id is required in file_content_request")
# Extract S3 URI from file ID
s3_uri: Final = self._extract_s3_uri_from_file_id(file_id)
configured_bucket_name: Final = self._get_configured_s3_bucket_name(optional_params)
bucket_name, object_key = self._parse_s3_uri(
s3_uri=s3_uri,
configured_bucket_name=configured_bucket_name,
allow_legacy_cloud_file_ids=should_allow_legacy_cloud_file_ids(optional_params),
)
# Get AWS credentials
aws_region_name: Final = self._get_aws_region_name(optional_params=optional_params, model="")
credentials: Final[Credentials] = self.get_credentials(
aws_access_key_id=optional_params.get("aws_access_key_id"),
aws_secret_access_key=optional_params.get("aws_secret_access_key"),
aws_session_token=optional_params.get("aws_session_token"),
aws_region_name=aws_region_name,
aws_session_name=optional_params.get("aws_session_name"),View on GitHub (pinned to 6c2dcb801b)
Solutions
- Always populate file_id from the create-file response (the 's3://...' managed id litellm returns).
- Validate the request payload before calling file_content().
- Log the incoming request when file_id is empty to find where it is dropped.
Example fix
# before content = handler.file_content(FileContentRequest(file_id=""), ...) # after file_obj = create_file(...) id_ = file_obj.id # managed s3:// file id content = handler.file_content(FileContentRequest(file_id=id_), ...)
Defensive patterns
Strategy: validation
Validate before calling
file_id = file_content_request.get("file_id")
if not file_id:
raise ValueError("file_id missing in caller payload") before invoking file_content() Type guard
def has_file_id(req: dict) -> bool:
fid = req.get("file_id")
return isinstance(fid, str) and len(fid) > 0 Try / catch
try:
content = handler.file_content(request, ...)
except ValueError as e:
if "file_id is required" in str(e):
return HTTP 400 to client
raise Prevention
- Validate file_id presence at the API boundary (path param required).
- Return the created file id to clients and require them to echo it back.
When it happens
Trigger: Calling the files content endpoint (GET /v1/files/{file_id}/content equivalent) with a missing or empty file_id — e.g. constructing FileContentRequest manually with file_id=None, or a routing bug that drops the path parameter.
Common situations: Custom integrations building the request dict themselves; proxy routing rules that rewrite the file id away; client code passing an f-string that evaluates empty.
Related errors
- Invalid S3 URI format: {s3_uri}
- output_s3_uri cannot be empty for async invoke requests
- Failed to download file from S3: {s3_uri}. Error: {e}
- file_id must be a managed LiteLLM S3 file id
- S3 bucket_name is required. Set 's3_bucket_name' in proxy co
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/c69cf5078d45bd16.
Report an issue: GitHub.