litellm/tests/test_litellm/proxy/hooks
Sameer Kankute 074455c138
fix(auth): expand all-team-models sentinel in can_key_call_model for batch validation (#29746)
* fix(auth): expand all-team-models sentinel in can_key_call_model

Keys with models=["all-team-models"] were denied during batch JSONL
model validation because can_key_call_model matched the literal string
against the model name. Add _resolve_key_models_for_auth_check to
expand the sentinel to team_models before the check, consistent with
get_key_models in model_checks.py and the completion-route bypass.

Co-authored-by: Cursor <cursoragent@cursor.com>

* docs(auth): document empty team_models unrestricted access behavior; add regression test

Adds a docstring note to _resolve_key_models_for_auth_check explaining that
when team_models is empty, all-team-models resolves to [] which is treated as
unrestricted access (consistent with get_key_models behavior on other auth
paths). Adds a test to lock in this behavior.

* fix(auth): deny all-team-models access when key has no team_id

A key configured with models=["all-team-models"] but no team_id could
previously resolve to an empty allowlist, which _check_model_access_helper
treats as unrestricted access. Now the sentinel is only expanded when
team_id is set; otherwise the unresolved sentinel stays in the model list
and causes a deny (no real model name matches it). Same fix applied to
get_key_models in model_checks.py for consistency across batch and
non-batch auth paths.

* style: black format model_checks.py

* Fix batch all-team-models auth

* style: black format batch_rate_limiter.py

* fix(test): add tool_use_system_prompt_tokens to model prices schema validator

* fix(batch): catch get_team_object errors to avoid 404 escaping batch auth

* fix(batch): apply per-member model scope check after team auth in batch validation

* Fail closed on batch team auth fetch errors

* test(batch): cover team_object grant and member-scope denial in batch auth

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com>
2026-06-05 09:04:45 -07:00
..
test_async_post_call_streaming_iterator_hook.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_batch_file_validation.py fix(auth): expand all-team-models sentinel in can_key_call_model for batch validation (#29746) 2026-06-05 09:04:45 -07:00
test_dynamic_rate_limiter_v3.py Include model name + configured TPM/RPM in priority rate-limit 429 er… (#27216) 2026-05-05 19:05:22 -07:00
test_image_generation_guardrails.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_key_management_event_hooks.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_max_budget_limiter.py [Fix] Proxy: Skip Personal Budget Hook When Reservation Covers Counter 2026-05-01 15:57:42 -07:00
test_max_budget_per_session_limiter.py
test_max_iterations_limiter.py
test_parallel_request_limiter_v3.py feat(proxy): add per-MCP-server RPM rate limiting for keys and teams (#29482) 2026-06-02 12:52:10 -07:00
test_post_call_failure_hook_integration.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_post_call_response_headers_hook.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_post_call_streaming_hook_integration.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_post_call_success_hook_integration.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_prompt_injection_detection.py
test_proxy_hooks_init.py [Fix] Proxy: Address Greptile feedback on hook-cycle PR 2026-05-04 20:13:31 -07:00
test_proxy_rate_limit_provider_field.py fix(proxy/hooks): populate llm_provider on internal rate-limit errors (#27707) 2026-06-04 22:46:08 -07:00
test_proxy_track_cost_callback.py fix: remove traceback key instead of it being "" 2026-05-01 20:49:49 -07:00
test_rate_limiter_toctou.py fix(rate-limit): fail closed on unrecognized OVER_LIMIT descriptor 2026-05-01 12:19:43 -07:00
test_send_invite_email.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_sensitive_data_routing.py [internal copy of #29511] feat(guardrails): add sensitive data routing to on-premise models (#29531) 2026-06-04 22:22:28 -07:00
test_tpm_concurrent.py fix(v3 limiter): cap no-max_tokens TPM floor at smallest configured limit (#28805) 2026-05-30 19:36:04 -07:00