Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Exception Group Traceback not fully visible using StdlibFormatter

Abierto
#185 6 comentarios 0 reacciones 0 asignados Ver en GitHub

@Shubham-Padkonde ya está trabajando en esto.

Desde el 21/9/2026.

  • #249 de @Shubham-Padkonde — abierto

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Necesita aclaración
Estado de actividad
Estancado
Stack tecnológico
python

Línea de trabajo

En el informe no se menciona ningún archivo fuente ni ninguna prueba del repositorio. Empieza reproduciendo un ExceptionGroup anidado mediante StdlibFormatter y compara su salida serializada con el traceback nativo de Uvicorn; después, localiza el manejo de excepciones del formateador y añade cobertura que demuestre que cada grupo anidado se conserva en los logs de ECS.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

agent-python community triage
Description

When logging a nested Exception Group traceback from within a custom middleware, only the first Exception Group appears to be captured in the logs. The complete error traceback—including nested or inner Exception Groups—is not recorded. It is unclear whether this is due to incorrect usage, a limitation in the formatter, or an issue with the logging integration.

Steps to Reproduce

Raise a nested Exception Group inside a FastAPI middleware.

Let FastAPI/Uvicorn with ECS logging enabled handle and log the exception.

Observe that only the first Exception Group appears in the logs, rather than the entire nested traceback.

Expected Behavior

The full nested traceback, including all Exception Groups, should be visible in the logs for proper diagnostics and troubleshooting.

Actual Behavior

Only the first Exception Group is recorded in the ECS logs, while deeper nested exceptions are missing.

Environment
  • Python: 3.9
  • fastapi: 0.99.1
  • uvicorn: 0.15
  • ecs-logging: 1.1.0
Logger init code snippet
import ecs_logging
import logging
import uvicorn

log_handler = logging.StreamHandler()
log_handler.setFormatter(ecs_logging.StdlibFormatter())
logging.basicConfig(handlers=[log_handler])

ecs_log_config = uvicorn.config.LOGGING_CONFIG
ecs_log_config['formatters']['ecs_logging'] = {
        '()': 'ecs_logging.StdlibFormatter'
}
ecs_log_config['handlers']['default']['formatter'] = 'ecs_logging'
ecs_log_config['handlers']['access']['formatter'] = 'ecs_logging'

uvicorn.run("app.api:fastapi_app", host=<API_HOST>, port=<API_PORT>, reload=API_HOT_RELOAD, log_config=ecs_log_config)
Additional Context

This issue specifically arises when exceptions are raised and logged within FastAPI middleware.

Example error sample using uvicorn native LOGGING_CONFIG
ERROR:    Exception in ASGI application
+ Exception Group Traceback (most recent call last):
|   File "/usr/local/lib/python3.9/site-packages/uvicorn/protocols/http/httptools_impl.py", line 409, in run_asgi
|     result = await app(  # type: ignore[func-returns-value]
|   File "/usr/local/lib/python3.9/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in __call__
|     return await self.app(scope, receive, send)
|   File "/usr/local/lib/python3.9/site-packages/fastapi/applications.py", line 290, in __call__
|     await super().__call__(scope, receive, send)
|   File "/usr/local/lib/python3.9/site-packages/starlette/applications.py", line 122, in __call__
|     await self.middleware_stack(scope, receive, send)
|   File "/usr/local/lib/python3.9/site-packages/elasticapm/instrumentation/packages/asyncio/starlette.py", line 48, in call
|     return await wrapped(*args, **kwargs)
|   File "/usr/local/lib/python3.9/site-packages/starlette/middleware/errors.py", line 184, in __call__
|     raise exc
|   File "/usr/local/lib/python3.9/site-packages/starlette/middleware/errors.py", line 162, in __call__
|     await self.app(scope, receive, _send)
|   File "/usr/local/lib/python3.9/site-packages/elasticapm/contrib/starlette/__init__.py", line 199, in __call__
|     await self.app(scope, _request_receive or receive, wrapped_send)
|   File "/usr/local/lib/python3.9/site-packages/starlette/middleware/cors.py", line 91, in __call__
|     await self.simple_response(scope, receive, send, request_headers=headers)
|   File "/usr/local/lib/python3.9/site-packages/starlette/middleware/cors.py", line 146, in simple_response
|     await self.app(scope, receive, send)
|   File "/usr/local/lib/python3.9/site-packages/ratelimit/core.py", line 96, in __call__
|     return await self.app(scope, receive, send)
|   File "/usr/local/lib/python3.9/site-packages/starlette/middleware/base.py", line 110, in __call__
|     response_sent.set()
|   File "/usr/local/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 772, in __aexit__
|     raise BaseExceptionGroup(
| exceptiongroup.ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
+-+---------------- 1 ----------------
  | Exception Group Traceback (most recent call last):
  |   File "/usr/local/lib/python3.9/site-packages/starlette/middleware/base.py", line 108, in __call__
  |     response = await self.dispatch_func(request, call_next)
  |   File "/code/app/core/middlewares/middlewares.py", line 51, in dispatch
  |     return await call_next(request)
  |   File "/usr/local/lib/python3.9/site-packages/starlette/middleware/base.py", line 84, in call_next
  |     raise app_exc
  |   File "/usr/local/lib/python3.9/site-packages/starlette/middleware/base.py", line 70, in coro
  |     await self.app(scope, receive_or_disconnect, send_no_error)
  |   File "/usr/local/lib/python3.9/site-packages/starlette/middleware/base.py", line 110, in __call__
  |     response_sent.set()
  |   File "/usr/local/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 772, in __aexit__
  |     raise BaseExceptionGroup(
  | exceptiongroup.ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
  +-+---------------- 1 ----------------
    | Traceback (most recent call last):
    |   File "/usr/local/lib/python3.9/site-packages/starlette/middleware/base.py", line 78, in call_next
    |     message = await recv_stream.receive()
    |   File "/usr/local/lib/python3.9/site-packages/anyio/streams/memory.py", line 111, in receive
    |     return self.receive_nowait()
    |   File "/usr/local/lib/python3.9/site-packages/anyio/streams/memory.py", line 104, in receive_nowait
    |     raise EndOfStream
    | anyio.EndOfStream
    |
    | During handling of the above exception, another exception occurred:
    |
    | Traceback (most recent call last):
    |   File "/usr/local/lib/python3.9/site-packages/starlette/middleware/base.py", line 108, in __call__
    |     response = await self.dispatch_func(request, call_next)
    |   File "/code/app/core/api/security.py", line 6, in dispatch
    |     response = await call_next(request)
    |   File "/usr/local/lib/python3.9/site-packages/starlette/middleware/base.py", line 84, in call_next
    |     raise app_exc
    |   File "/usr/local/lib/python3.9/site-packages/starlette/middleware/base.py", line 70, in coro
    |     await self.app(scope, receive_or_disconnect, send_no_error)
    |   File "/usr/local/lib/python3.9/site-packages/starlette/middleware/authentication.py", line 48, in __call__
    |     await self.app(scope, receive, send)
    |   File "/usr/local/lib/python3.9/site-packages/starlette/middleware/exceptions.py", line 79, in __call__
    |     raise exc
    |   File "/usr/local/lib/python3.9/site-packages/starlette/middleware/exceptions.py", line 68, in __call__
    |     await self.app(scope, receive, sender)
    |   File "/usr/local/lib/python3.9/site-packages/fastapi/middleware/asyncexitstack.py", line 20, in __call__
    |     raise e
    |   File "/usr/local/lib/python3.9/site-packages/fastapi/middleware/asyncexitstack.py", line 17, in __call__
    |     await self.app(scope, receive, send)
    |   File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line 718, in __call__
    |     await route.handle(scope, receive, send)
    |   File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line 276, in handle
    |     await self.app(scope, receive, send)
    |   File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line 66, in app
    |     response = await func(request)
    |   File "/usr/local/lib/python3.9/site-packages/fastapi/routing.py", line 241, in app
    |     raw_response = await run_endpoint_function(
    |   File "/usr/local/lib/python3.9/site-packages/fastapi/routing.py", line 167, in run_endpoint_function
    |     return await dependant.call(**values)
    |   File "/code/app/api/routers/users.py", line 1171, in logout
    |     session_id = await authorization_service.get_session_id_from_access_token(request.headers.get('authorization'))
    |   File "/code/app/core/keycloak/authorization.py", line 163, in get_session_id_from_access_token
    |     return openid_connect.decode_token(token=token, key=key).get('sid')
    |   File "/usr/local/lib/python3.9/site-packages/keycloak/keycloak_openid.py", line 379, in decode_token
    |     return jwt.decode(token, key, algorithms=algorithms, audience=self.client_id, **kwargs)
    |   File "/usr/local/lib/python3.9/site-packages/jose/jwt.py", line 169, in decode
    |     _validate_claims(
    |   File "/usr/local/lib/python3.9/site-packages/jose/jwt.py", line 495, in _validate_claims
    |     _validate_aud(claims, audience=audience)
    |   File "/usr/local/lib/python3.9/site-packages/j̇ose/jwt.py", line 362, in _validate_aud
    |     raise JWTClaimsError("Invalid audience")
    | jose.exceptions.JWTClaimsError: Invalid audience
Lenguaje dominante
Python
Estrellas
74
Forks
34
Merge medio
1 d 2 min
PR fusionados (30 d)
1

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de elastic/ecs-logging-python

Todos los issues de elastic/ecs-logging-python

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.