fix(proxy): only schedule the deprecation loop when alerting is configured
Some checks failed
LiteLLM Rust / rustfmt, clippy, test (push) Has been cancelled
Terraform Provider / gofmt, vet, build, test (push) Has been cancelled
Terraform Provider / Provider endpoints vs proxy OpenAPI schema (push) Has been cancelled

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
mateo 2026-08-11 00:05:24 +00:00
parent 25f343a547
commit 2fe152a1d2
2 changed files with 20 additions and 1 deletions

View file

@ -482,7 +482,11 @@ class ProxyLogging:
) # RUN HANGING REQUEST CHECK (if user wants to alert on hanging requests)
self.hanging_requests_check_started = True
if self.slack_alerting_instance is not None and not self.deprecation_check_started:
if (
self.alerting is not None
and self.slack_alerting_instance is not None
and not self.deprecation_check_started
):
asyncio.create_task(self.slack_alerting_instance._run_scheduled_deprecation_check())
self.deprecation_check_started = True

View file

@ -129,6 +129,21 @@ def test_startup_event_initializes_slack_and_callbacks(proxy_logging):
}
@pytest.mark.asyncio
async def test_startup_event_schedules_deprecation_check_before_its_alert_type_is_on(proxy_logging):
"""Alerting config can enable the deprecation alert after startup, so the loop must already be running"""
proxy_logging.alerting = ["slack"]
proxy_logging.slack_alerting_instance = MagicMock()
proxy_logging.slack_alerting_instance.alert_types = []
proxy_logging.slack_alerting_instance._run_scheduled_deprecation_check = AsyncMock()
proxy_logging._init_litellm_callbacks = MagicMock()
proxy_logging.startup_event(llm_router=None, redis_usage_cache=None)
assert proxy_logging.deprecation_check_started is True
proxy_logging.slack_alerting_instance._run_scheduled_deprecation_check.assert_called_once_with()
def test_startup_event_propagates_init_callbacks_failure_raises(proxy_logging):
proxy_logging.slack_alerting_instance = MagicMock()
proxy_logging.slack_alerting_instance.alert_types = []