Investigate increased event frequency after upgrade #8
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.
Title
Fix: Prevent TypeError in daily spend sorting with None values
Relevant issues
N/A
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
tests/litellm/directory, Adding at least 1 test is a hard requirement - see detailsmake test-unitType
🐛 Bug Fix
Changes
The daily spend batch processor was crashing with a
TypeErrorwhen sorting transactions. This occurred because optional fields likemodelorcustom_llm_providercould beNone(a scenario that became more frequent after a recent upgrade), and Python's sort cannot compareNonewith strings.This change normalizes the sort key for daily spend transactions by coercing potentially
Nonestring fields to empty strings ("") before sorting. This ensures robust sorting even when optional fields are absent. Additionally,mcp_namespaced_tool_namehas been included in the sort key for more deterministic ordering.Slack Thread