From 47ffbcd3d87b638ecc6d063363ba9437feb2f8ca Mon Sep 17 00:00:00 2001 From: Priyanka Sadam Date: Mon, 10 Aug 2026 05:16:01 +0000 Subject: [PATCH] fix(cost_calculator): narrow exception catch to model-not-found only Replace bare 'except Exception' with a targeted check for the 'isn't mapped yet' message, re-raising all other exceptions so real pricing failures remain visible. Adds noqa: BLE001 to satisfy the ruff strict budget. Addresses review feedback from greptile and veria-ai bots. --- litellm/cost_calculator.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/litellm/cost_calculator.py b/litellm/cost_calculator.py index 1ebfe4b8bdf..111c6568bec 100644 --- a/litellm/cost_calculator.py +++ b/litellm/cost_calculator.py @@ -606,7 +606,9 @@ def cost_per_token( service_tier=service_tier, data_residency=data_residency, ) - except Exception: + except Exception as e: # noqa: BLE001 + if "isn't mapped yet" not in str(e): + raise verbose_logger.debug( "cost_per_token: unknown model=%s, custom_llm_provider=openai. Returning 0.0, 0.0", model,