Skip to content

Remove request object from logging extra fields#72

Merged
davegaeddert merged 2 commits into
masterfrom
claude/investigate-otel-warning-LvwOK
May 21, 2026
Merged

Remove request object from logging extra fields#72
davegaeddert merged 2 commits into
masterfrom
claude/investigate-otel-warning-LvwOK

Conversation

@davegaeddert
Copy link
Copy Markdown
Member

Summary

Remove the request object from logging extra dictionaries across the codebase. Request objects are not JSON-serializable and can cause issues with structured logging systems.

Changes

  • middleware/hosts.py: Removed "request": request from the extra dict in the 400 warning log
  • logs/exceptions.py: Removed "request": request from the base extra dict used in exception logging
  • views/base.py: Removed "request": self.request from the extra dict in the 405 method not allowed log

Details

The request object was being passed in logging extra fields, but this causes problems with JSON serialization in structured logging. The relevant request information (path, method, status_code) is already being logged separately, so removing the request object itself doesn't lose important context while improving compatibility with logging backends.

https://claude.ai/code/session_014onNMrdDjC8tete8jMbCDA

The exception/405/host-validation log calls put the raw `Request`
object into `extra`. plain.connect's OTel `LoggingHandler` copies
every non-standard LogRecord attribute into OTel log attributes, and a
`Request` is not a valid attribute type — so `opentelemetry.attributes`
emits an "Invalid type Request for attribute value" warning on every
such record. Nothing reads `record.request`; the adjacent `path` key
already carries the useful context.

https://claude.ai/code/session_014onNMrdDjC8tete8jMbCDA
@davegaeddert davegaeddert enabled auto-merge (squash) May 21, 2026 01:07
@davegaeddert davegaeddert merged commit 6324e21 into master May 21, 2026
7 checks passed
@davegaeddert davegaeddert deleted the claude/investigate-otel-warning-LvwOK branch May 21, 2026 01:11
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 this pull request may close these issues.

2 participants