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

The middleware produces "KeyError: 'status'" sometimes. #42

Open
alex-kowalczyk opened this issue Nov 12, 2023 · 0 comments
Open

The middleware produces "KeyError: 'status'" sometimes. #42

alex-kowalczyk opened this issue Nov 12, 2023 · 0 comments

Comments

@alex-kowalczyk
Copy link

alex-kowalczyk commented Nov 12, 2023

The full stack below.

ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/app/.venv/lib/python3.11/site-packages/uvicorn/protocols/http/h11_impl.py", line 408, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 84, in __call__
    return await self.app(scope, receive, send)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.11/site-packages/starlette_context/middleware/raw_middleware.py", line 92, in __call__
    await self.app(scope, receive, send_wrapper)
  File "/app/.venv/lib/python3.11/site-packages/starlette/middleware/cors.py", line 83, in __call__
    await self.app(scope, receive, send)
  File "/app/.venv/lib/python3.11/site-packages/fastapi/applications.py", line 1106, in __call__
    await super().__call__(scope, receive, send)
  File "/app/.venv/lib/python3.11/site-packages/starlette/applications.py", line 122, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/app/.venv/lib/python3.11/site-packages/starlette/middleware/errors.py", line 184, in __call__
    raise exc
  File "/app/.venv/lib/python3.11/site-packages/starlette/middleware/errors.py", line 162, in __call__
    await self.app(scope, receive, _send)
  File "/app/.venv/lib/python3.11/site-packages/asgi_logger/middleware.py", line 64, in __call__
    self.log(scope, info)
  File "/app/.venv/lib/python3.11/site-packages/asgi_logger/middleware.py", line 67, in log
    self.logger.info(self.format, AccessLogAtoms(scope, info))
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.11/site-packages/asgi_logger/middleware.py", line 81, in __init__
    status = info["response"]["status"]
             ~~~~~~~~~~~~~~~~^^^^^^^^^^
KeyError: 'status'
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

Successfully merging a pull request may close this issue.

1 participant