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

Properly handle invalid Redis DB arguments #221

Open
fusion44 opened this issue Jul 9, 2023 · 1 comment
Open

Properly handle invalid Redis DB arguments #221

fusion44 opened this issue Jul 9, 2023 · 1 comment
Labels
bug Something isn't working v0.6.0-beta
Milestone

Comments

@fusion44
Copy link
Owner

fusion44 commented Jul 9, 2023

When starting the API with an invalid Redis DB it'll go in an infinite loop. The Redis DB is a hard requirement and thus the API should stop when encountering this error.

2023-07-09 17:55:07 | ℹ️ | logging.py:87 | Waiting for application startup.
2023-07-09 17:55:07 | ❌ | logging.py:87 | Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line 677, in lifespan
    async with self.lifespan_context(app) as maybe_state:
  File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line 566, in __aenter__
    await self._router.startup()
  File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line 654, in startup
    await handler()
  File "/code/./app/main.py", line 96, in on_startup
    await redis_plugin.init()
  File "/usr/local/lib/python3.9/site-packages/fastapi_plugins/_redis.py", line 197, in init
    await self.ping()
  File "/usr/local/lib/python3.9/site-packages/fastapi_plugins/_redis.py", line 217, in ping
    return await self.redis.ping()
  File "/usr/local/lib/python3.9/site-packages/redis/asyncio/client.py", line 526, in execute_command
    conn = self.connection or await pool.get_connection(command_name, **options)
  File "/usr/local/lib/python3.9/site-packages/redis/asyncio/connection.py", line 1404, in get_connection
    await connection.connect()
  File "/usr/local/lib/python3.9/site-packages/redis/asyncio/connection.py", line 622, in connect
    await self.on_connect()
  File "/usr/local/lib/python3.9/site-packages/redis/asyncio/connection.py", line 724, in on_connect
    if str_if_bytes(await self.read_response()) != "OK":
  File "/usr/local/lib/python3.9/site-packages/redis/asyncio/connection.py", line 868, in read_response
    raise response from None
redis.exceptions.ResponseError: DB index is out of range

2023-07-09 17:55:07 | ❌ | logging.py:87 | Application startup failed. Exiting.
@fusion44 fusion44 added bug Something isn't working v0.6.0-beta labels Jul 9, 2023
@fusion44 fusion44 added this to the V0.6.0-beta milestone Jul 9, 2023
@fusion44
Copy link
Owner Author

fusion44 commented Jul 9, 2023

The default max number of databases is 16. This error is thrown then we are over it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working v0.6.0-beta
Projects
None yet
Development

No branches or pull requests

1 participant