Skip to content

Commit

Permalink
fix: Handle when ip_address not available
Browse files Browse the repository at this point in the history
  • Loading branch information
jopemachine committed Apr 26, 2024
1 parent 28b609a commit ef09838
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/ai/backend/manager/api/ratelimit.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,12 @@ async def rlim_middleware(
response.headers["X-RateLimit-Window"] = str(_rlim_window)
return response
else:
ip_address = get_client_ip(request)
assert ip_address is not None, "Client IP Address is not provided"

root_ctx: RootContext = app["_root.context"]
rate_limit = root_ctx.local_config["manager"]["anonymous-ratelimit"]

if rate_limit is None:
ip_address = get_client_ip(request)

if not ip_address or rate_limit is None:
# No checks for rate limiting.
response = await handler(request)
# Arbitrary number for indicating no rate limiting.
Expand Down

0 comments on commit ef09838

Please sign in to comment.