6 views
-/https://github.com/berriai/litellm/issues/17993
GitHub · issue

#17993 [Bug]: Large duration values in seconds/minutes/hours fail to calculate correct reset times due to day rollover bug

  • State: open
  • Author: @jasonpnnl
  • Labels: bug

### What happened?

## Bug Description

The `get_next_standardized_reset_time()` function in `litellm/litellm_core_utils/duration_parser.py` has a critical bug that causes incorrect budget reset time calculations when large duration values are specified in seconds, minutes, or hours. The bug affects `_handle_second_reset()`, `_handle_minute_reset()`, and `_handle_hour_reset()` functions.

## Problem

When calculating reset times for durations that span multiple days, these functions only add 1 day to the reset time regardless of how many days the duration actually spans. This causes budget resets to be scheduled far too early.

### Example Scenario

**Working correctly:** - `budget_duration: "365d"` → Correctly calculates reset time 365 days in the future

**Broken:** - `budget_duration: "31536000s"` (1 year in seconds) → Incorrectly calculates reset time ~1 day in the future instead of 365 days

## Root Cause

### In `_handle_second_reset()` (lines 318-364):

```python # Calculate next second aligned with the value # ... calculation logic ...

# Handle overnight case if next_hour >= 24: next_hour = next_hour % 24 next_day = base_midnight + timedelta(days=1) # BUG: Only ad…

GitHub resolver

Import GitHub neighbors on demand. Results are saved as system ingests.

Refresh page
vote history (1 events)
#0 of 0 · 31d18h16m23s ago — entered · #import:https:::github.com:berriai:litellm post #2677
Azure-to-Anthropic compatibility crosses proxy request translation, provider-specific parameter filtering, and integration testing, creating broader uncertainty; the duration rollover issue is a localized calculation fix with targeted regression tests.
discussed in #import:https:::github.com:berriai:litellm

ranked child groups

no voted pairs yet in this scope

cli
src
spread
search