fix(budget): log warning when ZoneInfo falls back to UTC#21879
Open
LeeJuOh wants to merge 3 commits intoBerriAI:litellm_oss_staging_02_22_2026from
Open
fix(budget): log warning when ZoneInfo falls back to UTC#21879LeeJuOh wants to merge 3 commits intoBerriAI:litellm_oss_staging_02_22_2026from
LeeJuOh wants to merge 3 commits intoBerriAI:litellm_oss_staging_02_22_2026from
Conversation
When ZoneInfo fails to load a configured timezone (e.g. missing tzdata), the code silently falls back to UTC. Add a verbose_logger.warning() so operators can see which timezone failed and how to fix it.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Author
Contributor
Greptile SummaryThis PR adds a
Confidence Score: 5/5
|
| Filename | Overview |
|---|---|
| litellm/litellm_core_utils/duration_parser.py | Adds a verbose_logger.warning() call in the _setup_timezone() exception handler to log when timezone loading fails and falls back to UTC. Import added at module level. Minimal, well-scoped change. |
| tests/test_litellm/litellm_core_utils/test_duration_parser.py | Adds a mock-based test verifying that verbose_logger.warning is called when an invalid timezone triggers the UTC fallback. No real network calls; uses unittest.mock.patch. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[get_next_standardized_reset_time] --> B[_setup_timezone]
B --> C{timezone_str is None?}
C -->|Yes| D[Use timezone.utc]
C -->|No| E[ZoneInfo timezone_str]
E -->|Success| F[Return tz]
E -->|Exception| G["verbose_logger.warning() ⬅ NEW"]
G --> H[Fallback to timezone.utc]
D --> I[Convert current_time to target tz]
F --> I
H --> I
Last reviewed commit: 9397d3c
Author
Author
|
@krrishdholakia Could you review this when you have a chance? This is a follow-up to #21754. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Relevant issues
Follow-up to #21754
Pre-Submission checklist
tests/litellm/directory, Adding at least 1 test is a hard requirement - see detailsmake test-unit@greptileaiand received a Confidence Score of at least 4/5 before requesting a maintainer reviewType
🐛 Bug Fix
Changes
In #21754, the hardcoded
timezone_mapwas replaced withZoneInfo. On environments without thetzdatapackage,ZoneInfothrows an exception and silently falls back to UTC — operators have no way to tell their configured timezone is being ignored.Rather than adding
tzdataas a dependency, this PR adds averbose_logger.warning()in theexceptblock of_setup_timezone()to log when the fallback occurs.litellm/litellm_core_utils/duration_parser.py: Add warning log on timezone load failure