mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-03 02:22:24 +00:00
fix(ci): resolve post-merge test isolation leak and stale generated schema
- test_custom_pass_through_endpoint_prefix_wins_over_native_provider_routes registered routes directly on the shared litellm.proxy.proxy_server.app singleton with no teardown, leaking /claude-aws/v1/files and /claude-aws/v1/batches into app.router.routes for the rest of the test session. A newer upstream test, test_gateway_plus_backend_covers_full_app, then flags those as routes uncovered by either component's allowlist. Snapshot app.router.routes before the test and restore it in a finally block. - Regenerate ui/litellm-dashboard/src/lib/http/schema.d.ts (npm run gen:api) against the post-merge backend; the prior merge left it stale by two lines (a soft_budget docstring entry removed upstream).
This commit is contained in:
parent
655989e081
commit
2aa7fc934a
2 changed files with 27 additions and 22 deletions
|
|
@ -3413,28 +3413,35 @@ def test_custom_pass_through_endpoint_prefix_wins_over_native_provider_routes():
|
|||
)
|
||||
from litellm.proxy.proxy_server import app
|
||||
|
||||
for suffix in ("files", "batches"):
|
||||
InitPassThroughEndpointHelpers.add_exact_path_route(
|
||||
app=app,
|
||||
path=f"/claude-aws/v1/{suffix}",
|
||||
target=f"https://example.com/v1/{suffix}",
|
||||
custom_headers=None,
|
||||
forward_headers=False,
|
||||
merge_query_params=False,
|
||||
dependencies=None,
|
||||
cost_per_request=None,
|
||||
endpoint_id=f"test-claude-aws-{suffix}",
|
||||
)
|
||||
# app is the real, process-wide proxy app -- registering routes on it leaks
|
||||
# into every other test (e.g. test_component_allowlists.py's full-route-coverage
|
||||
# check) unless restored, so snapshot and restore app.router.routes afterward.
|
||||
original_routes = list(app.router.routes)
|
||||
try:
|
||||
for suffix in ("files", "batches"):
|
||||
InitPassThroughEndpointHelpers.add_exact_path_route(
|
||||
app=app,
|
||||
path=f"/claude-aws/v1/{suffix}",
|
||||
target=f"https://example.com/v1/{suffix}",
|
||||
custom_headers=None,
|
||||
forward_headers=False,
|
||||
merge_query_params=False,
|
||||
dependencies=None,
|
||||
cost_per_request=None,
|
||||
endpoint_id=f"test-claude-aws-{suffix}",
|
||||
)
|
||||
|
||||
assert _resolve_route_name("POST", "/claude-aws/v1/files") == "endpoint_func"
|
||||
assert _resolve_route_name("POST", "/claude-aws/v1/batches") == "endpoint_func"
|
||||
assert _resolve_route_name("POST", "/claude-aws/v1/files") == "endpoint_func"
|
||||
assert _resolve_route_name("POST", "/claude-aws/v1/batches") == "endpoint_func"
|
||||
|
||||
# registering a custom prefix must not disturb resolution of unrelated,
|
||||
# already-registered native-provider routes
|
||||
assert _resolve_route_name("POST", "/openai/v1/files") == "create_file"
|
||||
assert _resolve_route_name("GET", "/azure/v1/files") == "list_files"
|
||||
assert _resolve_route_name("POST", "/v1/files") == "create_file"
|
||||
assert _resolve_route_name("POST", "/v1/batches") == "create_batch"
|
||||
# registering a custom prefix must not disturb resolution of unrelated,
|
||||
# already-registered native-provider routes
|
||||
assert _resolve_route_name("POST", "/openai/v1/files") == "create_file"
|
||||
assert _resolve_route_name("GET", "/azure/v1/files") == "list_files"
|
||||
assert _resolve_route_name("POST", "/v1/files") == "create_file"
|
||||
assert _resolve_route_name("POST", "/v1/batches") == "create_batch"
|
||||
finally:
|
||||
app.router.routes = original_routes
|
||||
|
||||
|
||||
def test_move_before_generic_provider_routes_is_a_no_op_without_a_generic_route():
|
||||
|
|
|
|||
2
ui/litellm-dashboard/src/lib/http/schema.d.ts
generated
vendored
2
ui/litellm-dashboard/src/lib/http/schema.d.ts
generated
vendored
|
|
@ -16781,7 +16781,6 @@ export interface paths {
|
|||
* - permissions: Optional[dict] - [Not Implemented Yet] User-specific permissions, eg. turning off pii masking.
|
||||
* - metadata: Optional[dict] - Metadata for user, store information for user. Example metadata = {"team": "core-infra", "app": "app2", "email": "ishaan@berri.ai" }
|
||||
* - max_parallel_requests: Optional[int] - Rate limit a user based on the number of parallel requests. Raises 429 error, if user's parallel requests > x.
|
||||
* - soft_budget: Optional[float] - Get alerts when user crosses given budget, doesn't block requests.
|
||||
* - model_max_budget: Optional[dict] - Model-specific max budget for user. [Docs](https://docs.litellm.ai/docs/proxy/users#add-model-specific-budgets-to-keys)
|
||||
* - budget_fallbacks: Optional[Dict[str, List[str]]] - Per-model fallback chain tried in order when that model's own `model_max_budget` is exceeded, e.g. {"gpt-4o": ["gpt-4o-mini"]}.
|
||||
* - model_rpm_limit: Optional[float] - Model-specific rpm limit for user. [Docs](https://docs.litellm.ai/docs/proxy/users#add-model-specific-limits-to-keys)
|
||||
|
|
@ -16887,7 +16886,6 @@ export interface paths {
|
|||
* - permissions: Optional[dict] - [Not Implemented Yet] User-specific permissions, eg. turning off pii masking.
|
||||
* - metadata: Optional[dict] - Metadata for user, store information for user. Example metadata = {"team": "core-infra", "app": "app2", "email": "ishaan@berri.ai" }
|
||||
* - max_parallel_requests: Optional[int] - Rate limit a user based on the number of parallel requests. Raises 429 error, if user's parallel requests > x.
|
||||
* - soft_budget: Optional[float] - Get alerts when user crosses given budget, doesn't block requests.
|
||||
* - model_max_budget: Optional[dict] - Model-specific max budget for user. [Docs](https://docs.litellm.ai/docs/proxy/users#add-model-specific-budgets-to-keys)
|
||||
* - budget_fallbacks: Optional[Dict[str, List[str]]] - Per-model fallback chain tried in order when that model's own `model_max_budget` is exceeded, e.g. {"gpt-4o": ["gpt-4o-mini"]}.
|
||||
* - model_rpm_limit: Optional[float] - Model-specific rpm limit for user. [Docs](https://docs.litellm.ai/docs/proxy/users#add-model-specific-limits-to-keys)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue