diff --git a/litellm/proxy/common_utils/reset_budget_job.py b/litellm/proxy/common_utils/reset_budget_job.py index 5c0c6deb9be..35b10ab2f0d 100644 --- a/litellm/proxy/common_utils/reset_budget_job.py +++ b/litellm/proxy/common_utils/reset_budget_job.py @@ -565,7 +565,7 @@ class ResetBudgetJob: ) try: await redis_cache.async_delete_cache(key=counter_key) - except Exception as delete_err: + except Exception as delete_err: # noqa: BLE001 # any Redis failure here leaves the pre-reset value stuck; log and move on verbose_proxy_logger.error( "Failed to delete spend counter %s in Redis after its reset also failed; the " "pre-reset value stays authoritative until its TTL expires: %s", @@ -582,7 +582,7 @@ class ResetBudgetJob: try: current = await redis_cache.async_get_cache(key=counter_key) return float(current) if current is not None else 0.0 - except Exception as redis_err: + except Exception as redis_err: # noqa: BLE001 # any Redis failure here means no safe baseline; fall back to delete verbose_proxy_logger.warning( "Failed to read spend counter %s in Redis before reset; skipping the delta-preserving " "reset and falling back to delete: %s", @@ -606,7 +606,7 @@ class ResetBudgetJob: key=counter_key, new_base=new_spend, snapshot=snapshot, ttl=60 ) return True - except Exception as redis_err: + except Exception as redis_err: # noqa: BLE001 # any Redis failure here is worth a retry, not just specific ones is_last_attempt = attempt == RESET_BUDGET_SPEND_COUNTER_RESET_MAX_ATTEMPTS - 1 verbose_proxy_logger.warning( "Attempt %d/%d to reset spend counter %s in Redis failed: %s", diff --git a/litellm/proxy/spend_tracking/budget_reservation.py b/litellm/proxy/spend_tracking/budget_reservation.py index 9631eb216d6..6eed3df39f8 100644 --- a/litellm/proxy/spend_tracking/budget_reservation.py +++ b/litellm/proxy/spend_tracking/budget_reservation.py @@ -379,7 +379,7 @@ async def release_budget_reservation_on_cancel( ) except asyncio.CancelledError: pass # a second cancellation while shielded; the reconcile keeps running detached regardless - except Exception: + except Exception: # noqa: BLE001 # a reconcile failure must not pin the counter; retry, then drop it directly verbose_proxy_logger.exception( "Failed to reconcile budget reservation on cancel; retrying before invalidating reserved counters" ) @@ -389,7 +389,7 @@ async def release_budget_reservation_on_cancel( return try: await invalidate_budget_reservation_counters(budget_reservation=budget_reservation) - except Exception: + except Exception: # noqa: BLE001 # nothing left to try; the finalized stamp below keeps it from being reprocessed verbose_proxy_logger.exception( "Failed to invalidate budget reservation counters after cancel-path reconcile failed" ) @@ -408,7 +408,7 @@ async def _retry_reconcile_reservation_on_cancel( try: await reconcile_budget_reservation(budget_reservation=budget_reservation, actual_cost=incurred_cost) return True - except Exception: + except Exception: # noqa: BLE001 # any reconcile failure is worth a retry here, not just specific ones is_last_attempt = attempt == _RELEASE_ON_CANCEL_RECONCILE_MAX_ATTEMPTS - 1 verbose_proxy_logger.warning( "Retry %d/%d to reconcile budget reservation on cancel failed",