Skip to content

Commit

Permalink
fix: safeguard for empy tokens in remove_limited_team_tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
patricio-posthog committed Jan 3, 2025
1 parent 1b9aa47 commit 0b4b95c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ee/billing/quota_limiting.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ def add_limited_team_tokens(resource: QuotaResource, tokens: Mapping[str, int],


def remove_limited_team_tokens(resource: QuotaResource, tokens: list[str], cache_key: QuotaLimitingCaches) -> None:
# This check exists because the * unpacking operator
# doesn't return anything with an empty list,
# so zrem only receives one argument and it fails.
if not tokens:
return

redis_client = get_client()
redis_client.zrem(f"{cache_key.value}{resource.value}", *tokens)

Expand Down

0 comments on commit 0b4b95c

Please sign in to comment.