The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
fix(proxy): add LPOP pipeline error checking and fix org spend ServiceType
Ryan Crabbe68a30a39e68d
diff --git a/litellm/caching/redis_cache.py b/litellm/caching/redis_cache.pyindex 9b93d890cec..fa9b94bc2ac 100644--- a/litellm/caching/redis_cache.py+++ b/litellm/caching/redis_cache.py@@ -1511,6 +1511,11 @@ class RedisCache(BaseCache):raw_results.append(key_results if key_results else None)offset += count+ # Raise on per-command errors (matches _pipeline_rpush_helper behavior)+ for r in raw_results:+ if isinstance(r, Exception):+ raise r+# Decode bytes -> str for each result setdecoded_results: List[Optional[List[str]]] = []for r in raw_results:diff --git a/litellm/proxy/db/db_transaction_queue/redis_update_buffer.py b/litellm/proxy/db/db_transaction_queue/redis_update_buffer.pyindex ef8dbb2c7b8..504fc5aba02 100644--- a/litellm/proxy/db/db_transaction_queue/redis_update_buffer.py+++ b/litellm/proxy/db/db_transaction_queue/redis_update_buffer.py@@ -201,7 +201,7 @@ class RedisUpdateBuffer:(db_spend_update_transactions, REDIS_UPDATE_BUFFER_KEY, ServiceTypes.REDIS_SPEND_UPDATE_QUEUE),(daily_spend_update_transactions, REDIS_DAILY_SPEND_UPDATE_BUFFER_KEY, ServiceTypes.REDIS_DAILY_SPEND_UPDATE_QUEUE),(daily_team_spend_update_transactions, REDIS_DAILY_TEAM_SPEND_UPDATE_BUFFER_KEY, ServiceTypes.REDIS_DAILY_TEAM_SPEND_UPDATE_QUEUE),- (daily_org_spend_update_transactions, REDIS_DAILY_ORG_SPEND_UPDATE_BUFFER_KEY, ServiceTypes.REDIS_DAILY_SPEND_UPDATE_QUEUE),+ (daily_org_spend_update_transactions, REDIS_DAILY_ORG_SPEND_UPDATE_BUFFER_KEY, ServiceTypes.REDIS_DAILY_ORG_SPEND_UPDATE_QUEUE),(daily_end_user_spend_update_transactions, REDIS_DAILY_END_USER_SPEND_UPDATE_BUFFER_KEY, ServiceTypes.REDIS_DAILY_END_USER_SPEND_UPDATE_QUEUE),(daily_agent_spend_update_transactions, REDIS_DAILY_AGENT_SPEND_UPDATE_BUFFER_KEY, ServiceTypes.REDIS_DAILY_AGENT_SPEND_UPDATE_QUEUE),(daily_tag_spend_update_transactions, REDIS_DAILY_TAG_SPEND_UPDATE_BUFFER_KEY, ServiceTypes.REDIS_DAILY_TAG_SPEND_UPDATE_QUEUE),diff --git a/tests/test_litellm/caching/test_redis_cache.py b/tests/test_litellm/caching/test_redis_cache.pyindex 31eeb854883..82606511826 100644--- a/tests/test_litellm/caching/test_redis_cache.py+++ b/tests/test_litellm/caching/test_redis_cache.py@@ -296,6 +296,36 @@ async def test_async_rpush_pipeline_raises_on_per_command_error(monkeypatch, redawait redis_cache.async_rpush_pipeline(rpush_list=rpush_list)+async def test_async_lpop_pipeline_raises_on_per_command_error(monkeypatch, redis_no_ping):+ """Verify that per-command errors in LPOP pipeline results are raised, not silently dropped"""+ monkeypatch.setenv("REDIS_HOST", "https://my-test-host")+ redis_cache = RedisCache()+ redis_cache.redis_version = "7.0.0"++ mock_redis_instance = AsyncMock()+ mock_pipeline = MagicMock()+ mock_pipeline.__aenter__ = AsyncMock(return_value=mock_pipeline)+ mock_pipeline.__aexit__ = AsyncMock(return_value=None)+ mock_pipeline.lpop = MagicMock()+ # Simulate: first LPOP succeeds, second returns a per-command error+ mock_pipeline.execute = AsyncMock(+ return_value=[[b"val1"], Exception("WRONGTYPE")]+ )+ mock_redis_instance.pipeline = MagicMock(return_value=mock_pipeline)++ from litellm.types.caching import RedisPipelineLpopOperation++ lpop_list = [+ RedisPipelineLpopOperation(key="key1", count=10),+ RedisPipelineLpopOperation(key="key2", count=10),+ ]++ with patch.object(redis_cache, "init_async_client", return_value=mock_redis_instance):+ with pytest.raises(Exception, match="WRONGTYPE"):+ await redis_cache.async_lpop_pipeline(lpop_list=lpop_list)++@pytest.mark.asyncioasync def test_async_lpop_pipeline_empty_list(monkeypatch, redis_no_ping):"""Empty lpop_list should return empty list without touching Redis"""