fix: use sync context manager for structlog bound_contextvars

bound_contextvars() returns a sync _GeneratorContextManager, not async.
Using `async with` caused TypeError crashing all web API requests.
This commit is contained in:
Fringg
2026-02-16 09:23:22 +03:00
parent 1f0fef114b
commit 25e8c9f8fc
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -23,5 +23,5 @@ class ContextVarsMiddleware(BaseMiddleware):
ctx['username'] = event.from_user.username or ''
if hasattr(event, 'chat') and event.chat:
ctx['chat_id'] = event.chat.id
async with bound_contextvars(**ctx):
with bound_contextvars(**ctx):
return await handler(event, data)
+1 -1
View File
@@ -17,7 +17,7 @@ class RequestLoggingMiddleware(BaseHTTPMiddleware):
"""Логирование входящих запросов в административный API."""
async def dispatch(self, request: Request, call_next: RequestResponseEndpoint) -> Response:
async with bound_contextvars(http_method=request.method, http_path=request.url.path):
with bound_contextvars(http_method=request.method, http_path=request.url.path):
start = monotonic()
response: Response | None = None
try: