mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-11 03:38:38 +00:00
PR #10 closed the discovery-vs-inference gap on /v1/models for the LiteLLM_UserTable.models ("Personal Models") field, but a live audit on the internal proxy revealed two sibling endpoints still leaked the full deployment list to users restricted by user.models: - `GET /v1/model/info` (and the `/model/info` alias) on Path B (no `litellm_model_id` query param) — exposed by litellm's own Python SDK `client.models.info()` and by any curl / ops script. The endpoint self-rolled key/team filtering via `get_key_models + get_team_models + get_complete_model_list`, bypassing `_apply_user_models_filter` entirely. - `GET /v2/model/info` on the default (flagless) branch — the endpoint returned `llm_router.model_list` verbatim, exposing every deployment's `litellm_params` (including `api_base`) to any virtual-key holder. The UI doesn't trip this (always passes `include_team_models=true`), but a bare curl did. `litellm/proxy/auth/route_checks.py:189-191` already documents the intended behaviour: elif route == "/model/info": # /model/info just shows models user has access to pass so this is a spec-vs-impl gap, not a design question. Fix: 1. `model_info_v1` (proxy_server.py): Path B replaces the self-rolled key/team/complete-list with a single call to `get_available_models_for_user(...)` — same wiring as `/v1/models` and `/model_group/info`. The downstream model_name → deployment enrichment loop is preserved unchanged. 2. `model_info_v2` (proxy_server.py): inserts a final-step `apply_user_models_filter_to_deployments` call after enrichment. Runs unconditionally — any flag combination (default, `include_team_models=true`, `user_models_only=true`, `teamId=...`) is now bounded by user.models. 3. `apply_user_models_filter_to_deployments` (utils.py): thin async wrapper that lifts `_apply_user_models_filter` (operates on `List[str]` of model names) to operate on `List[Dict]` deployment dicts. Extracts distinct `model_name` set, runs the existing filter, returns the surviving deployments preserving original order and duplicates. Tests (4 tiers, 33 new cases): - Unit (`test_proxy_utils.py`): direct `apply_user_models_filter_to_deployments` exercising master-key passthrough, empty input, narrowing, no-default-models sentinel, empty user.models passthrough, missing-model_name defense — 6 cases. - Route-level FastAPI TestClient (`test_v1_model_info_user_filter.py`): real `/v1/model/info` and `/model/info` handler → real `get_available_models_for_user` → real `_apply_user_models_filter` → mocked `get_user_object`. Covers narrowing / empty user.models / master key / no-default-models / all-proxy-models / wildcard / key vs user precedence / alias route — 8 cases. - Route-level FastAPI TestClient (`test_v2_model_info_user_filter.py`): same 8 cases on the default branch, plus 3 cases mocking `get_all_team_and_direct_access_models` to verify user.models still narrows after team-access expansion (the UI's hot path) — 11 cases total. - E2E (`e2e/cases/17`): real proxy + Postgres, dynamic users via `/user/new` + `/key/generate`, asserts against `/v1/model/info`, `/v2/model/info`, and `/v2/model/info?include_team_models=true` in lockstep. Wired into `e2e/tools/run-all-cases`. Verified on the local e2e proxy: case 15 (PR #10 regression), case 16 (budget reset), case 17 (this change) all PASS. |
||
|---|---|---|
| .. | ||
| agent_tests | ||
| audio_tests | ||
| basic_proxy_startup_tests | ||
| batches_tests | ||
| benchmarks | ||
| code_coverage_tests | ||
| documentation_tests | ||
| e2e | ||
| enterprise | ||
| guardrails_tests | ||
| image_gen_tests | ||
| integration | ||
| litellm | ||
| litellm-proxy-extras | ||
| litellm_core_utils | ||
| litellm_utils_tests | ||
| llm_responses_api_testing | ||
| llm_translation | ||
| load_tests | ||
| local_testing | ||
| logging_callback_tests | ||
| mcp_tests | ||
| multi_instance_e2e_tests | ||
| ocr_tests | ||
| old_proxy_tests/tests | ||
| openai_endpoints_tests | ||
| otel_tests | ||
| pass_through_tests | ||
| pass_through_unit_tests | ||
| proxy_admin_ui_tests | ||
| proxy_behavior | ||
| proxy_e2e_anthropic_messages_tests | ||
| proxy_migration_tests | ||
| proxy_security_tests | ||
| proxy_unit_tests | ||
| router_unit_tests | ||
| scim_tests | ||
| search_tests | ||
| spend_tracking_tests | ||
| store_model_in_db_tests | ||
| test_litellm | ||
| unified_google_tests | ||
| vector_store_tests | ||
| windows_tests | ||
| __init__.py | ||
| _fake_openai_endpoint_server.py | ||
| _flush_vcr_cache.py | ||
| _live_test_helpers.py | ||
| _openai_record_replay_proxy.py | ||
| _vcr_conftest_common.py | ||
| _vcr_redis_persister.py | ||
| eval_swe_bench.py | ||
| fake_openai_endpoint.py | ||
| gettysburg.wav | ||
| large_text.py | ||
| openai_batch_completions.jsonl | ||
| pyrightconfig.json | ||
| README.MD | ||
| test_anthropic_compaction_usage.py | ||
| test_budget_management.py | ||
| test_callbacks_on_proxy.py | ||
| test_config.py | ||
| test_debug_warning.py | ||
| test_default_encoding_non_root.py | ||
| test_end_users.py | ||
| test_entrypoint.py | ||
| test_fallbacks.py | ||
| test_gpt5_azure_temperature_support.py | ||
| test_health.py | ||
| test_keys.py | ||
| test_litellm_proxy_responses_config.py | ||
| test_logging.conf | ||
| test_models.py | ||
| test_new_vector_store_endpoints.py | ||
| test_openai_endpoints.py | ||
| test_organizations.py | ||
| test_otel_thread_leak.py | ||
| test_passthrough_endpoints.py | ||
| test_presidio_latency.py | ||
| test_proxy_server_non_root.py | ||
| test_ratelimit.py | ||
| test_resource_cleanup.py | ||
| test_service_logger_otel.py | ||
| test_spend_logs.py | ||
| test_team.py | ||
| test_team_logging.py | ||
| test_team_members.py | ||
| test_users.py | ||
In total litellm runs 1000+ tests
[02/20/2025] Update:
To make it easier to contribute and map what behavior is tested,
we've started mapping the litellm directory in tests/test_litellm
This folder can only run mock tests.