litellm/tests/test_litellm/proxy/common_utils
ryan-crabbe-berri 83ab6e08da
fix(proxy): invalidate cached project object on project update and delete (#36028)
* fix(proxy): invalidate cached project object on /project/update and /project/delete

The auth path reads projects cache-first via get_project_object with a 60s
TTL and no freshness check, but no project write endpoint ever evicted the
project_id:{id} cache entry. A project cached before /project/update added a
model allowlist kept an empty models list in cache, so _run_project_checks
skipped can_project_access_model and project-bound keys could call team
models outside the project allowlist until the TTL expired. The same
staleness applied to blocked status and budget fields, and /project/delete
left the deleted project enforceable from cache.

Evict the cache entry after the DB write in update_project and
delete_project via a shared delete_cached_project_object helper, with the
cache key derivation shared with get_project_object.

* fix(proxy): broadcast project cache invalidation to all workers and make eviction best-effort

Single-worker eviction leaves every other worker serving its in-memory copy
of the mutated project until the 60s TTL expires, so a project allowlist
change was still bypassable on multi-worker deployments. Add a coordination
Redis pub/sub channel (litellm_proxy.auth_cache_invalidation): project
eviction publishes the cache key and a per-worker subscriber deletes the
local in-memory entry, with the next auth read refetching from the DB.
Subscriber starts on any deployment with a coordination Redis and falls back
to the TTL when none is configured.

Also wrap the eviction in a best-effort catch: the DB write has already
committed when eviction runs, so a cache backend error must not turn a
successful update into a 500 or abort the remaining ids in /project/delete.

* fix(lint): sort auth cache invalidation import and suppress best-effort shutdown catch

The strict-budget gate flagged the new import block as un-sorted (I001) and
the broad except in stop_auth_cache_invalidation_subscriber (BLE001); the
catch is intentional since a failing stop must not break proxy shutdown, so
it carries a named suppression instead of counting against the budget.
2026-08-07 15:19:00 +00:00
..
html_forms feat(proxy): configurable response headers and login-page hint (#30792) 2026-06-18 18:12:45 -07:00
test_auth_cache_invalidation_pubsub.py fix(proxy): invalidate cached project object on project update and delete (#36028) 2026-08-07 15:19:00 +00:00
test_cache_codec.py fix(proxy): stop CacheCodec dropping null fields on cache round-trip (#32207) 2026-07-06 12:53:00 -07:00
test_callback_utils.py fix(proxy): sanitize per-key callback config out of logged metadata 2026-07-24 22:16:50 -07:00
test_config_sync_pubsub.py fix(proxy): persist periodic reload schedule state so status survives restarts and fires without store_model_in_db (#35165) 2026-08-04 15:42:57 -07:00
test_custom_openapi_spec.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_encrypt_decrypt_utils.py fix(proxy): stop the decrypt-failure debug log from leaking the raw value 2026-07-03 13:03:45 -07:00
test_expired_ui_session_key_cleanup_manager.py Handle cleanup delete races and accurate counts 2026-04-25 03:01:34 +03:00
test_get_routes.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_http_parsing_utils.py perf(proxy): bound event-loop blocking from oversized requests (#31497) 2026-06-27 12:06:48 -07:00
test_json_merge_patch.py fix(team): bound json merge patch recursion depth 2026-07-11 09:36:15 -07:00
test_key_rotation_e2e.py Litellm key rotation bug (#27756) 2026-05-12 17:16:37 -07:00
test_key_rotation_integration.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_key_rotation_lock.py Litellm ishaan april4 2 (#25150) 2026-04-04 23:09:42 +00:00
test_key_rotation_manager.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_load_config_utils.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_openai_endpoint_utils.py fix(vector-stores): recurse into nested litellm_params; handle JSON-string shape 2026-04-29 18:56:40 +00:00
test_path_utils.py test: add unit tests for path_utils safe_join and safe_filename 2026-04-16 03:25:42 +00:00
test_periodic_reload_schedule.py fix(proxy): persist periodic reload schedule state so status survives restarts and fires without store_model_in_db (#35165) 2026-08-04 15:42:57 -07:00
test_reset_budget_job.py refactor(repositories): add prisma protocol seams and a spend-reset unit of work 2026-08-03 22:19:54 -07:00
test_sse_keepalive.py fix(proxy): tolerate non-scalar sse keepalive interval config shapes 2026-08-05 17:33:09 -07:00
test_static_asset_utils.py fix(static-assets): browser-load remote branding assets 2026-04-30 11:30:57 -07:00
test_timezone_utils.py feat(budgets): add configurable budget_reset_time of day (#31007) 2026-07-21 13:35:01 -07:00
test_upsert_budget_membership.py feat(ui): add budget duration to edit team member form (#29717) 2026-06-06 17:24:55 -07:00
test_user_api_key_cache.py fix(proxy/auth): honor user_api_key_cache_ttl for management-object cache writes (#31504) 2026-06-27 12:19:28 -07:00