{"record":{"id":"b041d9897a86bf99","repo":"BerriAI/litellm","slug":"contents-of-file-are-none","errorCode":null,"errorMessage":"contents of file are None","messagePattern":"contents of file are None","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/bedrock/files/transformation.py","lineNumber":1275,"sourceCode":"                headers=raw_response.headers,\n            )\n        return HttpxBinaryResponseContent(response=raw_response)\n\n\nclass BedrockJsonlFilesTransformation:\n    \"\"\"\n    Transforms OpenAI /v1/files/* requests to Bedrock S3 file uploads for batch processing\n    \"\"\"\n\n    def transform_openai_file_content_to_bedrock_file_content(\n        self, openai_file_content: FileTypes | None = None\n    ) -> tuple[str, str]:\n        \"\"\"\n        Transforms OpenAI FileContentRequest to Bedrock S3 file format\n        \"\"\"\n\n        if openai_file_content is None:\n            raise ValueError(\"contents of file are None\")\n        # Read the content of the file\n        file_content: Final = self._get_content_from_openai_file(openai_file_content)\n\n        # Split into lines and parse each line as JSON\n        openai_jsonl_content: Final = [json.loads(line) for line in file_content.splitlines() if line.strip()]\n        bedrock_jsonl_content = self._transform_openai_jsonl_content_to_bedrock_jsonl_content(openai_jsonl_content)\n        bedrock_jsonl_string: Final = \"\\n\".join(json.dumps(item) for item in bedrock_jsonl_content)\n        object_name: Final = self._get_s3_object_name(openai_jsonl_content=openai_jsonl_content)\n        return bedrock_jsonl_string, object_name\n\n    def _transform_openai_jsonl_content_to_bedrock_jsonl_content(\n        self, openai_jsonl_content: Sequence[_OpenAIBatchRecord]\n    ):\n        \"\"\"\n        Delegate to the main BedrockFilesConfig transformation method\n        \"\"\"\n        config: Final = BedrockFilesConfig()\n        return config._transform_openai_jsonl_content_to_bedrock_jsonl_content(openai_jsonl_content)","sourceCodeStart":1257,"sourceCodeEnd":1293,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/bedrock/files/transformation.py#L1257-L1293","documentation":"When converting an OpenAI-style file upload into a Bedrock batch JSONL file, the transformation requires actual file content. If openai_file_content is None (no file supplied in the request), it raises ValueError('contents of file are None') before any parsing. It is a request-shape guard on the /v1/files path for bedrock batches.","triggerScenarios":"POST /v1/files with purpose=... (batch) routed to Bedrock where the multipart 'file' field is missing, or calling transform_openai_file_content_to_bedrock_file_content programmatically with the default openai_file_content=None.","commonSituations":"Client SDK sends filename only without payload; a proxy in front of litellm strips the multipart body; misconfigured integration that builds the files payload from an empty variable.","solutions":["Include a non-empty JSONL file in the 'file' part of the multipart /v1/files request.","Each non-blank line must be valid JSON (an OpenAI batch record) – fix malformed lines before upload.","If calling the transformation directly, always pass FileTypes (bytes, file-like, or (filename, content) tuple), never None."],"exampleFix":"# before\nfiles = {\"file\": (\"batch.jsonl\", None)}  # -> ValueError\n# after\nfiles = {\"file\": (\"batch.jsonl\", jsonl_bytes, \"application/json\")}","handlingStrategy":"validation","validationCode":"import json\n\ndef valid_batch_file(content: bytes | None) -> bool:\n    if not content:\n        return False\n    lines = [l for l in content.decode(\"utf-8\").splitlines() if l.strip()]\n    if not lines:\n        return False\n    try:\n        [json.loads(l) for l in lines]\n        return True\n    except json.JSONDecodeError:\n        return False","typeGuard":"from typing import Any\n\ndef is_file_payload(v: Any) -> bool:\n    return v is not None and (\n        isinstance(v, (bytes, str)) or hasattr(v, \"read\") or isinstance(v, tuple)\n    )","tryCatchPattern":null,"preventionTips":["Always attach the JSONL file part when calling /v1/files for bedrock batches.","Validate JSONL lines parse as JSON before upload to fail fast client-side.","Never default the file argument; make it required in your internal wrappers."],"tags":["bedrock","files","batch","validation","jsonl"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}