fix(proxy): restore management_v1 query-param validation under fastapi>=0.140.7 - #35773
Merged
yuneng-berri merged 2 commits intoAug 9, 2026
Conversation
Contributor
Greptile SummaryThe PR restores
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| litellm/proxy/management_endpoints/management_v1/common.py | Replaces the removed FastAPI helper while preserving the existing query-only validation behavior. |
| tests/test_litellm/proxy/management_endpoints/management_v1/test_common.py | Adds focused, isolated coverage for accepted aliases, rejected unknown parameters, parameter-kind filtering, and absent route metadata. |
Reviews (2): Last reviewed commit: "test(proxy): lock in query-param validat..." | Re-trigger Greptile
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
fastapi 0.140.7 removed get_flat_dependant(), which broke the import in management_v1/common.py and took down every /management/v1 route. Switch to get_flat_params() and filter to ParamTypes.query so unknown-query-param rejection keeps matching the old behavior.
Guards _declared_query_params against a regression in the get_flat_params migration: the flatten step returns path, query, header and cookie params together, so a dropped ParamTypes.query filter would wrongly treat path or header names as declared query params and accept unknown ones. Removing the filter fails these tests.
HuanQian571
force-pushed
the
litellm_fix_management_v1_get_flat_params
branch
from
August 7, 2026 07:37
02fd50f to
da443d1
Compare
Contributor
Author
Contributor
Author
|
Hi, @yuneng-jiang |
Collaborator
|
Great catch. Thanks for this, LGTM |
yuneng-berri
approved these changes
Aug 9, 2026
yuneng-berri
merged commit Aug 9, 2026
ecba48d
into
BerriAI:litellm_internal_staging
82 of 83 checks passed
5 tasks
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:
get_flat_dependant()management_v1/common.py/management/v1route went down on that fastapiHow it solves it:
get_flat_params()ParamTypes.queryto keep the old behaviorRelevant issues
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
get_flat_dependant()exists through fastapi 0.140.6 and is gone from 0.140.7 onward, whileget_flat_params()has been present since well before that, so the runs below use a fastapi 0.141.1 interpreter to reproduce the breakage and confirm the fix. This fix touches only route wiring and never calls an LLM, so there is no real-dollar inference request to show; the proof instead drives the actualspend_logsroute with a real HTTP request (no mock of the guard under test) and only overrides auth so the request can reach the query-param guardBefore, at
4b7adab548(base, pre-fix) under fastapi 0.141.1: the module fails to import, so every route depending on it fails to registerAfter, at
da443d1266(this branch) under fastapi 0.141.1: the module loads and the real/management/v1/spend_logs/end_usersroute rejects an unknown query param with an RFC 9457 problem before touching the databaseThe
allowedset is exactly the route's declared query params, so theParamTypes.queryfilter kept path and header params out of itType
🐛 Bug Fix
Changes
_declared_query_paramsinmanagement_v1/common.pyusedget_flat_dependant(...).query_paramsto learn which query params a route declared, soreject_unknown_query_paramscould 400 anything else. fastapi 0.140.7 removedget_flat_dependant, so the module failed to import and took every/management/v1route with it. This swaps inget_flat_params(dependant), which returns the flat, deduped list of all param kinds, and filters toParamTypes.queryto recover exactly the old query-only set. Dedup that the oldskip_repeats=Truegave is now handled insideget_flat_paramstests/.../management_v1/test_common.pyadds regression coverage: it stands up a route with query, path and header params behindreject_unknown_query_paramsand asserts a declared query alias is accepted, an unknown one is a 400 problem, and path or header names are not mistaken for declared query params. Dropping theParamTypes.queryfilter fails the last groupFinal Attestation