BerriAI/litellm · error · ValueError
file content is required
Error message
file content is required
What it means
BedrockJsonlFilesTransformation.get_object_name() needs the uploaded file's bytes (via extracted_file_data['content']) both to name the object and, for batch purpose, to parse each JSONL line and derive the model-specific object name. Missing content means the extraction step failed or the caller bypassed it.
Source
Thrown at litellm/llms/bedrock/files/transformation.py:300
named as: litellm-bedrock-files/{model}/{uuid}
"""
_model = openai_jsonl_content[0].get("body", {}).get("model", "")
# Remove bedrock/ prefix if present
_model = _model.removeprefix("bedrock/")
safe_model: Final = sanitize_cloud_object_component(_model.replace(":", "-"), fallback="model")
object_name: Final = f"{BEDROCK_MANAGED_S3_BATCH_PREFIX}{safe_model}-{uuid.uuid4()}.jsonl"
return object_name
def get_object_name(self, extracted_file_data: ExtractedFileData, purpose: str) -> str:
"""
Get the object name for the request
"""
extracted_file_data_content: Final = extracted_file_data.get("content")
if extracted_file_data_content is None:
raise ValueError("file content is required")
if purpose == "batch":
## 1. If jsonl, check if there's a model name
file_content: Final = self._get_content_from_openai_file(extracted_file_data_content)
# Split into lines and parse each line as JSON
openai_jsonl_content: Final = [json.loads(line) for line in file_content.splitlines() if line.strip()]
if len(openai_jsonl_content) > 0:
return self._get_s3_object_name_from_batch_jsonl(openai_jsonl_content)
## 2. If not jsonl, store under a server-generated managed object name
filename: Final = extracted_file_data.get("filename")
return build_managed_cloud_object_name(
prefix=BEDROCK_MANAGED_S3_UPLOAD_PREFIX,
filename=filename,
fallback_filename="file",
)
View on GitHub (pinned to 6c2dcb801b)
Solutions
- Ensure the actual file bytes are attached as extracted_file_data['content'] (bytes) before upload.
- Use litellm's standard file upload flow rather than constructing ExtractedFileData by hand.
- If a framework consumed the stream, reset via await file.seek(0) before passing it on.
Defensive patterns
Strategy: validation
Validate before calling
def has_content(extracted_file_data: dict) -> bool:
return extracted_file_data.get("content") is not None Prevention
- Use litellm's standard upload flow; don't hand-build ExtractedFileData.
- In web frameworks, seek(0) the upload before passing it to litellm.
When it happens
Trigger: Calling create-file (upload) where extracted_file_data carries metadata only — content is None because the multipart file body was not read, or a custom File storage integration passed an already-consumed file object.
Common situations: Custom integrations constructing ExtractedFileData manually and omitting 'content'; a FastAPI/Starlette upload handler reading the stream before litellm does; tests with stub file objects lacking bytes.
Related errors
- file is required
- purpose is required
- File data is required
- file_id is required in file_content_request
- file_id must be a managed LiteLLM S3 file id
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/42d11425a2583ad2.
Report an issue: GitHub.