litellm/tests/unit/proxy/common_utils
paveln83 c904856114
fix(passthrough): find a new Azure AI Search index in the DB on a registry miss (#51098)
* fix(passthrough): find a new Azure AI Search index in the DB on a registry miss

An index created with POST /v1/indexes answered 500 on every instance until the periodic registry sync loaded it. The Azure passthrough now reads a missing index from the DB through the shared registry read-through, and an unknown index with no AZURE_API_BASE answers 404 naming the index.

* fix(proxy): read vector stores through the DB writer on first use for Azure, Milvus and OpenSearch passthroughs

A vector store created with POST /vector_store/new only reached the instance that served the create,
so the issue's own steps still answered 500 on the Azure passthrough and Milvus and OpenSearch searches
answered 400 until the periodic sync. The Azure, Milvus and OpenSearch passthroughs now look a missing
index and vector store up in the DB on first use through the shared read-through, and both reads go to
the DB writer so a lagging replica cannot turn a new index into a 404.

The route tests run the real app, access checks included, with only the upstream search service mocked.

* fix(proxy): reload the vector store index table at most once per 2s on a registry miss

A DB read per unknown index name let a burst of made-up names cost one read each and use up the shared read budget, so a real index created on another instance then missed again. On an index miss the Azure, Milvus and OpenSearch passthroughs now reload the whole index table from the DB writer, one reload in flight per worker and at most one every 2 seconds, success or failure, and a caller waits at most 1 second for it

With AZURE_API_BASE unset, a name the reload did not find answers 404 saying it is not loaded on this proxy, and a failed reload answers 503 asking to retry, since the index may exist. With AZURE_API_BASE set, both still relay as before

* fix(passthrough): load a created index on its own worker and answer 503 when the index read fails

POST /v1/indexes now loads the new index into the worker's registry, so that worker never waits out the reload cooldown. Milvus and OpenSearch answer the same retryable 503 as Azure when the index table read fails or runs past 1s, and the Azure 404 no longer mentions AZURE_API_BASE

The writer-pin test fakes now carry create, so the test fails when the pin is removed, and a new test checks that two stores with one name resolve to the newest

* fix(proxy): load a vector store renamed on another instance and say the index read timed out

A store lookup that found the name in the DB used to skip a store whose id was already loaded under its old name, so the
name never loaded and every request read the DB again. The lookup now updates the store by id and reports whether the
name loaded, so a miss is cached when it still is not there

The 503 for an index read that fails or passes 1s now says the read did not finish in time

* fix(proxy): keep the newest store first when a lookup loads a renamed one, and give reload tests a fake clock

* ci: re-run checks so the required zizmor check reports at this commit

* fix(proxy): answer 503 when the index table read fails on an AZURE_API_BASE proxy

A failed or timed-out index lookup used to relay the request to AZURE_API_BASE with the global key, skipping the managed index's own store and access checks. It now answers 503 asking to retry on every proxy, and a name the reload did not find still relays

* fix(proxy): skip index rows that fail validation in the index reload

One index row written outside the API without vector_store_name made the whole reload fail, so every index name the proxy had not loaded answered 503. Skip such rows with a warning and load the rest

* fix(proxy): let a relay proxy use a recent index read while the DB is slow

On a proxy with AZURE_API_BASE set, a search on an unmanaged index name
answered 503 whenever the index table read passed 1s or failed, even though
main relayed it. The relay decision now uses the last successful read when it
started in the past 10s, and still answers 503 after that.

* fix(proxy): keep relaying unmanaged Azure AI Search names while the index read is slow

Use the last good index read for up to the periodic sync interval, counted from when that read finished, so a relay proxy never decides on an older read than its own sync

* fix(proxy): relay unmanaged Azure AI Search names when the index read fails

A proxy with AZURE_API_BASE set relays a name to it when the index table read fails or passes 1s, as main does, instead of answering 503. This drops the 30s stale window, which only delayed those 503s during a DB writer outage

---------

Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com>
2026-11-26 08:29:21 +00:00
..
html_forms feat(proxy): delete the old username and password login page (#53205) 2026-11-20 22:41:08 +00:00
__init__.py
test_admin_ui_utils.py test(proxy): move middleware, spend_tracking, pass_through, common_utils and root proxy tests into tests/unit/proxy (#44015) 2026-10-01 18:23:31 +00:00
test_budget_alerts.py feat(proxy): add team budget percentage email alerts (#52859) 2026-11-19 16:21:25 -08:00
test_cache_aware_routing.py refactor(router): route the router family through RoutingContext and close the outside surface (#49118) 2026-10-30 19:18:54 -07:00
test_cache_codec.py test(proxy): move middleware, spend_tracking, pass_through, common_utils and root proxy tests into tests/unit/proxy (#44015) 2026-10-01 18:23:31 +00:00
test_cache_invalidation_pubsub.py refactor(auth_cache_invalidation): move the invalidation channel to the native client (#51135) 2026-11-21 18:58:27 +09:00
test_callback_config_validation.py fix(proxy): normalize metadata logging and tolerate malformed stored values (#51719) 2026-11-23 10:57:37 -08:00
test_callback_lifecycle.py feat(proxy): run callback setup and cleanup hooks during the proxy lifespan (#52908) 2026-11-19 12:17:05 -08:00
test_callback_utils.py feat(otel): add option to disable background service spans (#54478) 2026-11-25 12:28:04 -08:00
test_check_batch_cost.py fix(batches): keep the endpoint a batch was created for on retrieve, cancel and cost polling (#50784) 2026-11-24 05:42:08 -08:00
test_check_responses_cost.py test(spend): expect soft budget duration in customer scopes (#53017) 2026-11-20 16:52:06 +00:00
test_codex_catalog_source.py feat(proxy): serve Codex its own release's model catalog, fetched from GitHub (#50318) 2026-11-06 21:58:54 +00:00
test_codex_model_catalog.py fix(proxy): send the whole Codex model catalog to Codex 0.166.0-alpha.1 and newer (#50736) 2026-11-10 07:10:30 +00:00
test_codex_model_translation.py fix(proxy): list images in the Codex catalog only for models known to read them (#50738) 2026-11-10 03:46:37 +00:00
test_codex_version.py fix(proxy): send the whole Codex model catalog to Codex 0.166.0-alpha.1 and newer (#50736) 2026-11-10 07:10:30 +00:00
test_config_sync_pubsub.py feat(rust-gateway): read the stored config again when the proxy announces a change on Redis (#54054) 2026-11-25 03:26:50 +00:00
test_credential_hydration.py fix(secret_managers)!: resolve oidc/file and oidc/env refs in admin-configured api_key per request (#47341) 2026-10-20 01:43:59 +00:00
test_custom_openapi_spec.py docs(proxy): describe /v1/decisions and /v1/systemone in Swagger UI (#45838) 2026-10-10 21:04:59 +00:00
test_customer_budget_headers.py feat(proxy): opt-in response headers for app customer org and member budgets per window (#54483) 2026-11-25 13:18:53 -08:00
test_customer_usage.py feat(proxy): let an app set its own surcharge on customer requests (#52492) 2026-11-18 19:56:06 +00:00
test_debug_utils.py fix(router): keep the prompt caching affinity pin alive as long as the prefix's cache_control ttl (#46084) 2026-10-14 21:10:09 -07:00
test_discoverable_model_filter.py test(proxy): move middleware, spend_tracking, pass_through, common_utils and root proxy tests into tests/unit/proxy (#44015) 2026-10-01 18:23:31 +00:00
test_encrypt_decrypt_utils.py feat(fips): encrypt stored secrets with the FIPS provider's AES-256-GCM in fips_mode (#51429) 2026-11-18 03:22:53 +00:00
test_error_body_call_id.py test(proxy): move middleware, spend_tracking, pass_through, common_utils and root proxy tests into tests/unit/proxy (#44015) 2026-10-01 18:23:31 +00:00
test_expired_ui_session_key_cleanup_manager.py test(proxy): move middleware, spend_tracking, pass_through, common_utils and root proxy tests into tests/unit/proxy (#44015) 2026-10-01 18:23:31 +00:00
test_fips.py feat(proxy)!: require a LITELLM_SALT_KEY of at least 112 bits to start in fips_mode (#52099) 2026-11-17 12:58:59 -08:00
test_get_routes.py test(proxy): move middleware, spend_tracking, pass_through, common_utils and root proxy tests into tests/unit/proxy (#44015) 2026-10-01 18:23:31 +00:00
test_hook_cache.py refactor(auth_cache): type auth cache keys and keep the cache always native (#51130) 2026-11-21 17:20:30 +09:00
test_http_parsing_utils.py fix(auth): enforce key budgets on Google generateContent calls that leave the model out of the URL (#53404) 2026-11-22 22:04:46 +00:00
test_json_merge_patch.py test(proxy): move middleware, spend_tracking, pass_through, common_utils and root proxy tests into tests/unit/proxy (#44015) 2026-10-01 18:23:31 +00:00
test_key_expiry_alert_manager.py feat: email key owners before opted-in virtual keys expire (#51482) 2026-11-14 13:47:16 -08:00
test_key_rotation_e2e.py test(proxy): move middleware, spend_tracking, pass_through, common_utils and root proxy tests into tests/unit/proxy (#44015) 2026-10-01 18:23:31 +00:00
test_key_rotation_integration.py fix(security): remove the publicly known master key from the repo (#44718) 2026-10-06 10:55:24 -07:00
test_key_rotation_lock.py test(proxy): move middleware, spend_tracking, pass_through, common_utils and root proxy tests into tests/unit/proxy (#44015) 2026-10-01 18:23:31 +00:00
test_key_rotation_manager.py test(proxy): move middleware, spend_tracking, pass_through, common_utils and root proxy tests into tests/unit/proxy (#44015) 2026-10-01 18:23:31 +00:00
test_ldap_directory.py feat(proxy): sync LDAP groups to team memberships (#50130) 2026-11-24 11:13:49 -08:00
test_ldap_sync.py feat(proxy): sync LDAP groups to team memberships (#50130) 2026-11-24 11:13:49 -08:00
test_load_config_utils.py fix(bedrock): derive the web identity session policy per AWS caller (#50592) 2026-11-08 19:13:53 +00:00
test_model_deprecation.py refactor(rust_bridge): route every Rust-to-Python call through host modules (#50822) 2026-11-11 01:57:54 +00:00
test_model_listing_utils.py fix(proxy): resolve model aliases to their target deployment for listing metadata (#41041) 2026-10-15 00:38:50 -07:00
test_openai_endpoint_utils.py feat(router): add the Switchyard stage router as an auto router strategy (#50407) 2026-11-06 12:07:57 -08:00
test_openai_error_payload.py fix(proxy): redact credential-named provider error fields that the name check skipped (#54302) 2026-11-24 23:54:47 +00:00
test_openapi_route.py fix(proxy): build the OpenAPI schema off the event loop so a cold /openapi.json no longer stalls the worker (#47352) 2026-10-20 04:31:37 +00:00
test_openapi_schema_compat.py fix(proxy): build the OpenAPI schema off the event loop so a cold /openapi.json no longer stalls the worker (#47352) 2026-10-20 04:31:37 +00:00
test_periodic_reload_schedule.py test(proxy): move middleware, spend_tracking, pass_through, common_utils and root proxy tests into tests/unit/proxy (#44015) 2026-10-01 18:23:31 +00:00
test_proxy_encrypt_decrypt.py fix(security): remove the publicly known master key from the repo (#44718) 2026-10-06 10:55:24 -07:00
test_proxy_rate_limit_error.py feat(proxy): router_settings.fallback_on_saturation walks key and team fallbacks before a model saturates, replacing team model_preferences (#51439) 2026-11-13 05:57:18 +00:00
test_rbac_utils.py refactor(proxy): expose public names for private proxy helpers (#45170) 2026-10-07 18:59:27 -07:00
test_realtime_cache.py feat(realtime)!: support latest OpenAI audio models (#35600) 2026-11-03 07:27:52 +00:00
test_registry_read_through.py fix(passthrough): find a new Azure AI Search index in the DB on a registry miss (#51098) 2026-11-26 08:29:21 +00:00
test_request_tag_mappings.py refactor(auth_cache): type auth cache keys and keep the cache always native (#51130) 2026-11-21 17:20:30 +09:00
test_reset_budget_job.py feat(proxy)!: carry unused budget into the next period with a cap (#53309) 2026-11-22 02:05:03 -08:00
test_resource_ownership.py refactor(core_utils): move resource_ownership out of the proxy (#45805) 2026-10-10 21:02:53 +00:00
test_scheduled_job_stagger.py test(proxy): move middleware, spend_tracking, pass_through, common_utils and root proxy tests into tests/unit/proxy (#44015) 2026-10-01 18:23:31 +00:00
test_semantic_text_index.py fix(mcp): leave out tool texts too long to embed instead of failing tool search (#43554) 2026-10-14 14:53:00 -07:00
test_slow_gc_logger.py test(e2e): event_loop_stalls perf case fails on a gateway event-loop hold over 100 ms that is not on its allowlist (#46974) 2026-10-17 06:55:53 +00:00
test_sse_keepalive.py fix(guardrails): classify only the frames each read completes in Presidio's first-frame wait (#54379) 2026-11-25 11:15:49 +00:00
test_static_asset_utils.py test(proxy): move middleware, spend_tracking, pass_through, common_utils and root proxy tests into tests/unit/proxy (#44015) 2026-10-01 18:23:31 +00:00
test_swagger_utils.py test(proxy): move middleware, spend_tracking, pass_through, common_utils and root proxy tests into tests/unit/proxy (#44015) 2026-10-01 18:23:31 +00:00
test_timezone_utils.py fix(budgets): preserve calendar periods across DST (#53065) 2026-11-20 15:27:05 -08:00
test_token_count_log.py fix(proxy): answer x-litellm-call-id on every token count response (#51037) 2026-11-11 22:26:47 +00:00
test_token_count_settings.py fix(count_tokens): count grok-4-1, grok-4.3 and DeepSeek V4.1 tool requests the way their hosts bill them (#49074) 2026-11-02 12:37:35 -08:00
test_upsert_budget_membership.py fix(proxy): keep a temp budget increase on a team default member following the team default (#54307) 2026-11-25 02:21:37 +00:00
test_user_api_key_cache.py perf(proxy): read only the needed team fields from the auth cache (#53909) 2026-11-23 12:53:14 -08:00
test_validation_error_body.py fix(proxy): keep the submitted body out of 422 validation errors (#43231) 2026-09-25 17:05:53 -07:00