{"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":1329,"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":1311,"sourceCodeEnd":1347,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/bedrock/files/transformation.py#L1311-L1347","documentation":"BedrockJsonlFilesTransformation.transform_openai_file_content_to_bedrock_file_content requires the OpenAI file content; passing None (the parameter default) raises immediately. This helper converts an OpenAI batch JSONL payload into Bedrock's recordId/modelInput JSONL before upload, so a None payload is always a caller bug upstream.","triggerScenarios":"Calling the transformation helper with its default argument — e.g. a wrapper that loads file content, swallows the load error, and passes the resulting None; or code paths that call it unconditionally with an optional variable.","commonSituations":"Loader functions returning None on missing files instead of raising; optional file arguments threaded through to the transform; test scaffolding invoking the helper without arguments.","solutions":["Make your loader raise (or return a sentinel you check) instead of silently yielding None","Guard the call: if content is None, fail with your own actionable error naming the missing file","Pass the opened file/tuple from the same code that verified it exists"],"exampleFix":"# before\ncontent = load_jsonl(path)  # returns None if file missing\nbedrock_str, name = transform.transform_openai_file_content_to_bedrock_file_content(content)\n\n# after\ncontent = load_jsonl(path)\nif content is None:\n    raise FileNotFoundError(path)\nbedrock_str, name = transform.transform_openai_file_content_to_bedrock_file_content(content)","handlingStrategy":"validation","validationCode":"def load_jsonl_or_raise(path: str):\n    try:\n        return open(path, \"rb\")\n    except OSError as e:\n        raise FileNotFoundError(f\"batch file unavailable: {path}\") from e","typeGuard":"def has_content(payload: object) -> bool:\n    return payload is not None","tryCatchPattern":"try:\n    bedrock_str, object_name = transform.transform_openai_file_content_to_bedrock_file_content(content)\nexcept ValueError as e:\n    if str(e) == \"contents of file are None\":\n        raise FileNotFoundError(\"batch payload never loaded\") from e\n    raise","preventionTips":["Make loaders raise on failure instead of returning None","Check payload is not None at the call site with a descriptive error","Type helper signatures as FileTypes (not FileTypes | None) so None fails static checks"],"tags":["bedrock","batch","jsonl","missing-parameter","litellm"],"backgroundTag":"missing-required-argument","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}