diff --git a/litellm/litellm_core_utils/duration_parser.py b/litellm/litellm_core_utils/duration_parser.py index 39cd14b2b4e..d93639b1f4f 100644 --- a/litellm/litellm_core_utils/duration_parser.py +++ b/litellm/litellm_core_utils/duration_parser.py @@ -363,4 +363,4 @@ def _handle_month_reset(current_time: datetime, base_midnight: datetime, value: second=0, microsecond=0, tzinfo=current_time.tzinfo, - ) \ No newline at end of file + ) diff --git a/tests/test_duration_parser.py b/tests/test_duration_parser.py new file mode 100644 index 00000000000..9f780c1c3f6 --- /dev/null +++ b/tests/test_duration_parser.py @@ -0,0 +1,12 @@ +import pytest +from litellm.litellm_core_utils.duration_parser import duration_in_seconds + +def test_unlimited_budget_duration(): + # 1. Test that the bug is fixed (Empty/None values safely return None) + assert duration_in_seconds("None") is None + assert duration_in_seconds("null") is None + assert duration_in_seconds("") is None + assert duration_in_seconds(None) is None + + # 2. Test that normal math still works (30 days = 2,592,000 seconds) + assert duration_in_seconds("30d") == 2592000 \ No newline at end of file