fix(budget): log warning when ZoneInfo falls back to UTC#21879
fix(budget): log warning when ZoneInfo falls back to UTC#21879LeeJuOh wants to merge 3 commits intoBerriAI:mainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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() except block to log when timezone loading fails and UTC fallback occurs. Clean, minimal change with correct lazy string formatting. |
| tests/test_litellm/litellm_core_utils/test_duration_parser.py | Adds a mock-based test verifying the warning log is emitted when an invalid timezone is provided. No real network calls; consistent with existing test patterns. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["_setup_timezone(current_time, timezone_str)"] --> B{timezone_str is None?}
B -- Yes --> C["tz = timezone.utc"]
B -- No --> D["tz = ZoneInfo(timezone_str)"]
D -- Success --> E["Convert current_time to tz"]
D -- Exception --> F["⚠️ verbose_logger.warning\n'Failed to load timezone...'"]
F --> G["tz = timezone.utc (fallback)"]
C --> E
G --> E
E --> H["Return (current_time, tz)"]
Last reviewed commit: 2a35755
|
@krrishdholakia Could you review this when you have a chance? This is a follow-up to #21754. |
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.
9397d3c to
2a35755
Compare
|
@krrishdholakia Rebased onto latest main and updated the PR base branch (the previous target |
Review1. Does this PR fix the issue it describes? 2. Has this issue already been solved elsewhere? 3. Are there other PRs addressing the same problem? 4. Are there other issues this potentially closes? ✅ LGTM — minimal change, no new dependencies, preserves fallback behavior with observability. |
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