Skip to content

Fix: handle proxy internal callbacks in callback management test #12294

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

colesmcintosh
Copy link
Collaborator

Title

Fix: handle proxy internal callbacks in callback management test

Relevant issues

Fixes test failure in test_list_callbacks_mixed_callback_types when running tests in parallel

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • I have added a screenshot of my new test passing locally
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem

Type

🐛 Bug Fix

Changes

  • Modified test_list_callbacks_mixed_callback_types to filter out proxy-internal callbacks that can persist when tests run in parallel
  • Added filtering logic to handle _PROXY_VirtualKeyModelMaxBudgetLimiter callback that gets added by the proxy server initialization
  • This ensures test isolation and prevents failures when tests are executed in parallel using pytest-xdist

The test was failing with:

AssertionError: assert 'prometheus' in ['_PROXY_VirtualKeyModelMaxBudgetLimiter']

This happened because when tests run in parallel, the proxy server's internal callbacks can persist across test runs. The fix filters out these internal callbacks from the test assertions.

Test Results

All tests now pass:

$ poetry run pytest tests/test_litellm/proxy/management_endpoints/test_callback_management_endpoints.py -xvs -n 4
...
======================== 5 passed, 17 warnings in 5.33s ========================

The test_list_callbacks_mixed_callback_types test was failing when run in parallel with other tests due to the proxy server's internal _PROXY_VirtualKeyModelMaxBudgetLimiter callback persisting across test runs. This fix filters out proxy internal callbacks from the test assertions to ensure consistent test behavior regardless of test execution order or parallelization.
Copy link

vercel bot commented Jul 3, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
litellm ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 3, 2025 9:23pm

@ishaan-jaff
Copy link
Contributor

cc @jugaldb

@ishaan-jaff ishaan-jaff merged commit adfe63c into BerriAI:main Jul 3, 2025
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants