litellm/tests/unit/proxy/health_endpoints
Mateo Wang 51ceaf3481
fix(health): keep configured credentials when test_connection carries custom pricing (internal copy of #41024) (#55887)
* fix(health): probe test_connection without custom-pricing fields

/health/test_connection returns "Missing credentials. Please pass one of
api_key, azure_ad_token, ..." for a healthy configured model as soon as the
request also carries any custom-pricing field.

_request_inherits_config_credentials drops the configured connection when
the request sets one of _BANNED_CONNECTION_PARAMS. That list is
_BANNED_REQUEST_BODY_PARAMS minus the Vertex target fields, and it still
ends with every CustomPricingLiteLLMParams field. Those fields are banned
from a request body because they poison the shared model-cost registry, not
because they retarget or re-authenticate the outbound call. The Admin UI's
Add Model wizard sends them next to "Test Connection", so the button reports
a working deployment as broken.

- _BANNED_CONNECTION_PARAMS now also excludes the custom-pricing fields.
  The request-body check is unchanged, so pricing fields stay banned there.
- The probe strips custom-pricing fields from its params, whether they came
  from the request or from the configuration: completion registers request
  pricing under the shared {provider}/{model} cost-map key (a probe has no
  router deployment id), which would re-price every sibling deployment.

Measured against a configured azure deployment: {"model": ...} succeeds,
{"model": ..., "input_cost_per_token": 1e-9} failed and now succeeds, and
{"api_base": ..., "input_cost_per_token": 1e-9} still drops the configured
credentials.

* fix(health): keep only the connection-param gate change for test_connection pricing

The probe-pricing strip is a no-op on main, since completion no longer writes request pricing into the shared cost map. Drop it with its tests and the structure-only tests, and cover every pricing field through the gate instead

* fix(health): price a test_connection probe by the deployment, not the request

Prices sent with a test no longer reach the probe, so its spend row uses the model's configured price while the configured key still applies

---------

Co-authored-by: Mihidum Hettiyahandi <55163074+mihidumh@users.noreply.github.com>
2026-12-02 19:15:59 -08:00
..
__init__.py test(proxy): move utils, agent_endpoints and endpoint tests into tests/unit/proxy (#44006) 2026-10-01 11:06:42 -07:00
test_deployment_warning_endpoints.py feat(db): add the SQLx pool foundation with the writer pool (#49798) 2026-11-14 15:28:10 -08:00
test_graceful_shutdown_endpoints.py test(proxy): move utils, agent_endpoints and endpoint tests into tests/unit/proxy (#44006) 2026-10-01 11:06:42 -07:00
test_health_endpoints.py fix(health): keep configured credentials when test_connection carries custom pricing (internal copy of #41024) (#55887) 2026-12-02 19:15:59 -08:00