From a02cd094591b07cc0919b0bdd1696ae8a2dd8aad Mon Sep 17 00:00:00 2001 From: yumoqing Date: Fri, 31 Jul 2026 15:42:51 +0800 Subject: [PATCH] fix: Redis connection error now returns no_redis fallback instead of 429 --- llmage/balance.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/llmage/balance.py b/llmage/balance.py index 76aa840..b706e24 100644 --- a/llmage/balance.py +++ b/llmage/balance.py @@ -179,11 +179,12 @@ async def reserve_balance(env, llmid, userorgid, luid): return {'ok': True, 'max_cost': _from_cents(result[1])} except RuntimeError: - debug('reserve_balance: Redis unavailable, skip') + debug('reserve_balance: Redis not configured, skip') return {'ok': True, 'max_cost': 0, 'no_redis': True} except Exception as e: - exception(f'reserve_balance error: {e}') - return {'ok': False, 'reason': str(e)} + # Redis down or unreachable — fall back to DB check, don't block + debug(f'reserve_balance: Redis error, falling back to DB: {e}') + return {'ok': True, 'max_cost': 0, 'no_redis': True} async def finalize_balance(env, luid, actual_cost):