diff --git a/litellm/proxy/openai_files_endpoints/batch_file_validation.py b/litellm/proxy/openai_files_endpoints/batch_file_validation.py index bf6f6e2f829..0aee5e8cc54 100644 --- a/litellm/proxy/openai_files_endpoints/batch_file_validation.py +++ b/litellm/proxy/openai_files_endpoints/batch_file_validation.py @@ -108,7 +108,7 @@ def check_batch_file_upload( ) -> BatchFileValidationFailure | None: if filename is None or not filename.lower().endswith(".jsonl"): return BatchFileWrongExtension(filename=filename or "") - if max_batch_file_size_mb is not None: + if max_batch_file_size_mb is not None and max_batch_file_size_mb > 0: size_bytes: Final = _file_size_bytes(file_source) if size_bytes > max_batch_file_size_mb * _MB: return BatchFileTooLarge(size_bytes=size_bytes, limit_mb=max_batch_file_size_mb) diff --git a/tests/test_litellm/proxy/openai_files_endpoint/test_files_batch_file_validation.py b/tests/test_litellm/proxy/openai_files_endpoint/test_files_batch_file_validation.py index b4b0c5eb492..f5542fc0446 100644 --- a/tests/test_litellm/proxy/openai_files_endpoint/test_files_batch_file_validation.py +++ b/tests/test_litellm/proxy/openai_files_endpoint/test_files_batch_file_validation.py @@ -69,6 +69,12 @@ def test_no_cap_skips_size_check(): assert check_batch_file_upload("batch.jsonl", content, None) is None +@pytest.mark.parametrize("cap", [0, -3]) +def test_nonpositive_cap_disables_size_check(cap): + content = (VALID_LINE + b"\n") * 5000 + assert check_batch_file_upload("batch.jsonl", content, cap) is None + + @pytest.mark.parametrize("content", [b"", b"\n\n", b" \n\t\n"]) def test_empty_file_rejected(content): assert check_batch_file_upload("batch.jsonl", content, None) == BatchFileEmpty()