From be7fd219be3ae0b2a907342a751f957c233a4852 Mon Sep 17 00:00:00 2001 From: RoyVivat Date: Mon, 6 Apr 2026 16:01:18 -0700 Subject: [PATCH] Fix early-return guard ignoring clear_budget_duration flag When clear_budget_duration=True with all budget limits None, the guard at the top of _upsert_budget_and_membership was short-circuiting to disconnect the budget, bypassing the intended update. Adding `not clear_budget_duration` to the guard condition lets the function reach the update path. Co-Authored-By: Claude Sonnet 4.6 --- litellm/proxy/management_endpoints/common_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/litellm/proxy/management_endpoints/common_utils.py b/litellm/proxy/management_endpoints/common_utils.py index 8937abca7af..b2355697d2d 100644 --- a/litellm/proxy/management_endpoints/common_utils.py +++ b/litellm/proxy/management_endpoints/common_utils.py @@ -376,7 +376,7 @@ async def _upsert_budget_and_membership( If max_budget, tpm_limit, rpm_limit, and budget_duration are all None, the user's budget is removed from the team membership. If any of these values exist, a budget is updated or created and linked to the team membership. """ - if max_budget is None and tpm_limit is None and rpm_limit is None and budget_duration is None: + if max_budget is None and tpm_limit is None and rpm_limit is None and budget_duration is None and not clear_budget_duration: # disconnect the budget since all limits are None await tx.litellm_teammembership.update( where={"user_id_team_id": {"user_id": user_id, "team_id": team_id}},