test(proxy): guard management_v1 against fastapi names removed in supported releases - #36336
Merged
yuneng-berri merged 1 commit intoAug 10, 2026
Conversation
Contributor
Greptile SummaryAdds regression coverage for compatibility with supported FastAPI releases.
Confidence Score: 5/5The test-only pull request appears safe to merge. The added tests cover the known removed FastAPI import and simulated module-loading regression without changing production behavior or introducing a concrete test failure.
|
| Filename | Overview |
|---|---|
| tests/test_litellm/proxy/management_endpoints/management_v1/test_common.py | Adds focused static and import-time regression tests for removed FastAPI dependency names; no actionable defect was identified. |
Reviews (1): Last reviewed commit: "test(proxy): guard management_v1 against..." | Re-trigger Greptile
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
ryan-crabbe-berri
approved these changes
Aug 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
TLDR
Problem this solves:
How it solves it:
common.pyagainst a fastapi that no longer has themUser Flow
This PR adds tests only and changes no runtime behaviour, so there is no before and after for an end user. The flow below is the one that broke, and the one these tests keep broken code from reaching again
Before, on the module #35773 replaced, for anyone whose install resolved fastapi 0.140.7 or newer:
pip install 'litellm[proxy]', which allowsfastapi>=0.136.3,<1.0and so resolves 0.141.1ImportError: cannot import name 'get_flat_dependant' from 'fastapi.dependencies.utils'/management/v1/*, becauseproxy_serverimports the package unguarded at module levelAfter #35773, on the same install:
pip install 'litellm[proxy]'and get the same fastapi 0.141.1GET /management/v1/spend_logs/end_users?bogus=1answers 400 with the problem body as it does on 0.136.3Relevant issues
Follow-up to #35773
Linear ticket
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
@greptileaito re-request a review after pushing changes)Delays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
Screenshots / Proof of Fix
This PR is tests only, so the proof is that the new tests fail on the module #35773 replaced and pass on the one it merged. No LLM is reachable from this code path, so there is no inference call to show
Red, at
00600c1af7withcommon.pyreverted to its content ate9d1ea59fb(the staging tip immediately before #35773 merged):The 10 that pass there include all 6 tests from #35773, which is the gap this PR closes
Green, at
00600c1af7on merged staging (ecba48dd7c):The behaviour the tests stand in for, driven through
TestClientagainst the realproxy_server.appon an install pinned to fastapi 0.141.1, atecba48dd7c:The 503s are the absent database, not the routing. On the same interpreter at
e9d1ea59fbthe process never gets that far, sinceimport litellm.proxy.proxy_serveritself raisesType
✅ Test
Changes
test_no_module_imports_a_fastapi_name_removed_in_a_supported_releaseparses every.pyinmanagement_v1/and fails if it imports a fastapi name a supported release has deleted. It globs the directory, so a module added later is covered without anyone remembering to list ittest_common_still_imports_when_fastapi_has_dropped_those_namesdeletes the name fromfastapi.dependencies.utilsand loadscommon.pyfrom source, which is the closest a run on 0.136.3 gets to the failure a user on 0.141.1 sees. Behaviour cannot be asserted under that simulation, because 0.136.3'sget_flat_paramscallsget_flat_dependantinternally and raisesNameErroronce it is gone. The same reason is why the check stops atcommon.py:budgets.pyandspend_logs.pyregister routes at import, and registration reaches the deleted name on 0.136.3 no matter how the module is writtenKnown limitation, stated rather than buried:
FASTAPI_NAMES_REMOVED_IN_0_140_7is hand-maintained, so this catches the removal we know about and not the next one. The durable version is a CI job that resolves the newest fastapi our range allows and runs this suite against it. That is a separate change and I would rather verify it on a real run than bundle it hereFinal Attestation