Skip to content

v0.5.1 — Starlette exception-path request log

Latest

Choose a tag to compare

@heysamtexas heysamtexas released this 11 Jun 16:01
· 1 commit to main since this release
bc2c49b

Mirrors the v0.5.0 Django exception-path fix onto the Starlette/pure-ASGI middleware (#44).

uv add "git+https://github.com/collide-ai/collide-logging-py.git@v0.5.1"

Fixed

  • starlette.RequestLoggingMiddleware skipped the http.request line when the wrapped app raised (#44). The line was emitted after await self.app(...) returned, so an unhandled exception jumped past it into the finally and the genuinely-unhandled 500 produced no request log. The middleware now emits a status-500 http.request line at error level with the traceback (exc_info) before re-raising. No response exists on that path, so X-Request-ID is not set and the status is reported as 500 even if http.response.start already fired; request_id still rides the bound contextvar. ASGI analogue of the Django exception-path fix shipped in v0.5.0.

Notes

  • The streaming-duration (#41) and client-disconnect (#42) concerns do not apply to pure-ASGI: await self.app(...) returns only after the body drains, so its duration_ms is already correct.
  • CLAUDE.md gains a "Request logging guarantees" section documenting the cross-adapter middleware contract, including the open #42 Django known limitation.

Full prior history: v0.5.0 (Django middleware overhaul) — see CHANGELOG.