You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An initial request (empty history) to the FastAPI raises the following error:
File "/home/vscode/.local/lib/python3.12/site-packages/request_limiter_middleware/requests_archive.py", line 31, in add_ip
if type(self.history[ip]) is not bool: # if the IP is permanently banned
│ │ └ '172.22.0.5'
│ └ {}
└ <request_limiter_middleware.requests_archive.RequestsArchive object at 0x7f8b9f6ed5b0>
KeyError: '172.22.0.5'
The text was updated successfully, but these errors were encountered:
Hi, this error occurs as here uses the direct key access, try using if
`self.history.get(ip) not True` instead.
I'd appreciate it if you implement it and open a pull request. I don't have
time to support the package.
On Wed, Jun 19, 2024 at 7:38 PM Johannes Koch ***@***.***> wrote:
Hi
Using fastapi-request-limiter 1.0.1, fastapi 0.110.3, Python 3.12.3.
from request_limiter_middleware import RequestLimitMiddleware
...app = FastAPI()
...app.add_middleware(RequestLimitMiddleware, seconds=1, whitelisted_ip_addresses=())
...
An initial request (empty history) to the FastAPI raises the following
error:
File "/home/vscode/.local/lib/python3.12/site-packages/request_limiter_middleware/requests_archive.py", line 31, in add_ip
if type(self.history[ip]) is not bool: # if the IP is permanently banned
│ │ └ '172.22.0.5'
│ └ {}
└ <request_limiter_middleware.requests_archive.RequestsArchive object at 0x7f8b9f6ed5b0>
KeyError: '172.22.0.5'
—
Reply to this email directly, view it on GitHub
<#1>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AFN3MU7VE5N62JMZK35LK5TZIF3TNAVCNFSM6AAAAABJR7L2DCVHI2DSMVQWIX3LMV43ASLTON2WKOZSGM3DEMRYGA2DOMY>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
Hi
Using fastapi-request-limiter 1.0.1, fastapi 0.110.3, Python 3.12.3.
An initial request (empty history) to the FastAPI raises the following error:
The text was updated successfully, but these errors were encountered: