snok / asgi-correlation-id

Request ID propagation for ASGI apps
MIT License
414 stars 32 forks source link

TypeError: cannot use a bytes pattern on a string-like object #28

Closed janluke closed 2 years ago

janluke commented 2 years ago

Just a quick report, likely a bug. This happens with v1.1.3 but not with v1.1.2.

2022-03-21 14:29:13,652 | INFO    | [8752a841] 127.0.0.1:1124 - "POST /started HTTP/1.1" 405 | uvicorn.access:443
2022-03-21 14:29:13,655 | ERROR   | [8752a841] Exception in ASGI application
 | uvicorn.error:381
Traceback (most recent call last):
  File "h:\repo\unbox\unboxapi\venv\lib\site-packages\uvicorn\protocols\http\httptools_impl.py", line 378, in run_asgi
    result = await app(self.scope, self.receive, self.send)
  File "h:\repo\unbox\unboxapi\venv\lib\site-packages\uvicorn\middleware\proxy_headers.py", line 75, in __call__
    return await self.app(scope, receive, send)
  File "h:\repo\unbox\unboxapi\venv\lib\site-packages\uvicorn\middleware\message_logger.py", line 82, in __call__
    raise exc from None
  File "h:\repo\unbox\unboxapi\venv\lib\site-packages\uvicorn\middleware\message_logger.py", line 78, in __call__
    await self.app(scope, inner_receive, inner_send)
  File "h:\repo\unbox\unboxapi\venv\lib\site-packages\fastapi\applications.py", line 208, in __call__
    await super().__call__(scope, receive, send)
  File "h:\repo\unbox\unboxapi\venv\lib\site-packages\starlette\applications.py", line 112, in __call__
    await self.middleware_stack(scope, receive, send)
  File "h:\repo\unbox\unboxapi\venv\lib\site-packages\starlette\middleware\errors.py", line 181, in __call__
    raise exc
  File "h:\repo\unbox\unboxapi\venv\lib\site-packages\starlette\middleware\errors.py", line 159, in __call__
    await self.app(scope, receive, _send)
  File "h:\repo\unbox\unboxapi\venv\lib\site-packages\asgi_correlation_id\middleware.py", line 69, in __call__
    await self.app(scope, receive, handle_outgoing_request)
  File "h:\repo\unbox\unboxapi\venv\lib\site-packages\starlette\middleware\base.py", line 56, in __call__
    await response(scope, receive, send)
  File "h:\repo\unbox\unboxapi\venv\lib\site-packages\starlette\responses.py", line 227, in __call__
    await wrap(partial(self.listen_for_disconnect, receive))
  File "h:\repo\unbox\unboxapi\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 574, in __aexit__
    raise exceptions[0]
  File "h:\repo\unbox\unboxapi\venv\lib\site-packages\starlette\responses.py", line 223, in wrap
    await func()
  File "h:\repo\unbox\unboxapi\venv\lib\site-packages\starlette\responses.py", line 205, in stream_response
    await send(
  File "h:\repo\unbox\unboxapi\venv\lib\site-packages\asgi_correlation_id\middleware.py", line 67, in handle_outgoing_request
    await send(message)
  File "h:\repo\unbox\unboxapi\venv\lib\site-packages\starlette\middleware\errors.py", line 156, in _send
    await send(message)
  File "h:\repo\unbox\unboxapi\venv\lib\site-packages\uvicorn\middleware\message_logger.py", line 72, in inner_send
    await send(message)
    if HEADER_RE.search(name):
TypeError: cannot use a bytes pattern on a string-like object
sondrelg commented 2 years ago

Sorry for the late response, I must have missed this. Is the problem resolved in v1.1.4 @janluke?

janluke commented 2 years ago

Sorry, I've not had time to try this out but I guess you did if you closed the issue.

sondrelg commented 2 years ago

v1.1.3 was basically a bugged release. I haven't double checked, but if it worked in v1.1.2, it should work in v1.1.4 👍 Please feel free to double check though