Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError in RequestsArchive.add_ip() #1

Open
johakoch opened this issue Jun 19, 2024 · 1 comment
Open

KeyError in RequestsArchive.add_ip() #1

johakoch opened this issue Jun 19, 2024 · 1 comment
Assignees

Comments

@johakoch
Copy link

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'
@Armen-Jean-Andreasian
Copy link
Owner

Armen-Jean-Andreasian commented Jun 19, 2024 via email

@Armen-Jean-Andreasian Armen-Jean-Andreasian self-assigned this Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants