{"record":{"id":"7875f18464e7f838","repo":"BerriAI/litellm","slug":"file-is-required","errorCode":null,"errorMessage":"file is required","messagePattern":"file is required","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/bedrock/files/transformation.py","lineNumber":345,"sourceCode":"    ) -> str:\n        \"\"\"\n        Get the complete S3 URL for the file upload request\n        \"\"\"\n        request_params: Final = merge_bedrock_aws_request_params(litellm_params, optional_params)\n        bucket_name = litellm_params.get(\"s3_bucket_name\") or os.getenv(\"AWS_S3_BUCKET_NAME\")\n        if not bucket_name:\n            raise ValueError(\n                \"S3 bucket_name is required. Set 's3_bucket_name' in litellm_params or AWS_S3_BUCKET_NAME env var\"\n            )\n        bucket_name, object_prefix = split_configured_cloud_bucket_name(bucket_name)\n\n        s3_region_name: Final = litellm_params.get(\"s3_region_name\") or optional_params.get(\"s3_region_name\")\n        aws_region_name: Final = s3_region_name or self._get_aws_region_name(request_params, model)\n\n        file_data: Final = data.get(\"file\")\n        purpose: Final = data.get(\"purpose\")\n        if file_data is None:\n            raise ValueError(\"file is required\")\n        if purpose is None:\n            raise ValueError(\"purpose is required\")\n        extracted_file_data: Final = extract_file_data(file_data)\n        object_name = self.get_object_name(extracted_file_data, purpose)\n        if object_prefix:\n            object_name = f\"{object_prefix}/{object_name}\"\n        encoded_object_name: Final = encode_s3_object_key_for_url(object_name)\n\n        # S3 endpoint URL format\n        s3_endpoint_url: Final = (\n            request_params.get(\"s3_endpoint_url\") or f\"https://s3.{aws_region_name}.amazonaws.com\"\n        ).rstrip(\"/\")\n\n        return f\"{s3_endpoint_url}/{bucket_name}/{encoded_object_name}\"\n\n    def get_supported_openai_params(self, model: str) -> list[OpenAICreateFileRequestOptionalParams]:\n        return []\n","sourceCodeStart":327,"sourceCodeEnd":363,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/bedrock/files/transformation.py#L327-L363","documentation":"The Bedrock create-file handler requires the multipart 'file' field; data.get('file') returned None, so there are no bytes to extract, name, and PUT to S3. This guard runs before purpose validation.","triggerScenarios":"POSTing a files request without the multipart file part — malformed form data, wrong field name ('file' vs 'fileUpload'), or a JSON body where a file cannot be represented.","commonSituations":"Client sends JSON instead of multipart/form-data; field name mismatch between client SDK and litellm's expected 'file'; proxies stripping multipart parts; tests posting metadata only.","solutions":["Send the request as multipart/form-data with a part named exactly 'file'.","Verify with curl: curl -F file=@batch.jsonl -F purpose=batch .../v1/files.","Fix client SDK form construction to include the file part."],"exampleFix":"# before (no file part)\nrequests.post(url, json={\"purpose\": \"batch\"})\n\n# after\nrequests.post(url, files={\"file\": open(\"batch.jsonl\", \"rb\")}, data={\"purpose\": \"batch\"})","handlingStrategy":"validation","validationCode":"assert data.get(\"file\") is not None, \"multipart field 'file' is required\"","typeGuard":null,"tryCatchPattern":"try:\n    resp = litellm.create_file(file=f, purpose=\"batch\")\nexcept ValueError as e:\n    if \"file is required\" in str(e):\n        return HTTP 400  # client must send multipart\n    raise","preventionTips":["Always POST files as multipart/form-data with field name 'file'.","Add request-schema validation at the API gateway for upload endpoints."],"tags":["bedrock","files","upload","validation","multipart"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}