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.
This commit is contained in:
Priyanka Sadam 2026-08-10 05:16:01 +00:00
parent ed43c74bfa
commit 47ffbcd3d8

View file

@ -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,