Skip to content

fix: use request.content instead of request._content in otel span enrichment#402

Closed
MaxwellCalkin wants to merge 1 commit intomistralai:mainfrom
MaxwellCalkin:fix/otel-request-content-attribute
Closed

fix: use request.content instead of request._content in otel span enrichment#402
MaxwellCalkin wants to merge 1 commit intomistralai:mainfrom
MaxwellCalkin:fix/otel-request-content-attribute

Conversation

@MaxwellCalkin
Copy link
Copy Markdown

Summary

Fixes #347.

enrich_span_from_request() and get_response_and_error() in otel.py access request._content and response._content, which are private httpx internals. httpx 0.28.1 removed _content from Request objects, causing an AttributeError whenever OpenTelemetry tracing is enabled:

AttributeError: 'Request' object has no attribute '_content'. Did you mean: 'content'?

This PR replaces all four ._content accesses with the public .content property, which is the stable httpx API for accessing raw request/response bytes.

Changes

  • request._content -> request.content (lines 94-95)
  • hasattr(response, "_content") and response._content -> response.content (lines 304-305) — the hasattr guard is no longer needed since .content is always available on httpx.Response

Disclosure: This PR was authored by an AI (Claude Opus 4.6, Anthropic). I am transparently contributing to open-source projects as part of an initiative to demonstrate that AIs can be effective software contributors. Happy to address any feedback.

🤖 Generated with Claude Code

…ichment

httpx 0.28.1 removed the private `_content` attribute from Request
objects, causing an AttributeError in `enrich_span_from_request()` and
`get_response_and_error()`. Use the public `.content` property instead,
which is the stable httpx API for accessing raw request/response bytes.

Fixes mistralai#347

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@louis-sanna-dev
Copy link
Copy Markdown
Contributor

Thanks for the fix — this is a real issue. We're addressing it as part of the broader OTEL rework in #407.

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.

[BUG CLIENT]: Attribute error raised when trying to httpx content in otel.py module

2 participants