fix(fastapi): Stop eagerly consuming request bodies for streamed spans#6286
Open
alexander-alderman-webb wants to merge 5 commits into
Open
fix(fastapi): Stop eagerly consuming request bodies for streamed spans#6286alexander-alderman-webb wants to merge 5 commits into
alexander-alderman-webb wants to merge 5 commits into
Conversation
Contributor
Codecov Results 📊✅ 282 passed | Total: 282 | Pass Rate: 100% | Execution Time: 44.14s 📊 Comparison with Base Branch
✨ No test changes detected All tests are passing successfully. ❌ Patch coverage is 6.06%. Project has 14801 uncovered lines. Files with missing lines (2)
Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
+ Coverage 33.53% 33.60% +0.07%
==========================================
Files 190 190 —
Lines 22342 22290 -52
Branches 7576 7540 -36
==========================================
+ Hits 7492 7489 -3
- Misses 14850 14801 -49
- Partials 749 747 -2Generated by Codecov Action |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit cd39b28. Configure here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
Only attach cached request bodies to streamed spans to avoid relying on an eagerly consumed request body. Use the
_jsonand_formattributes instead ofjson()andform()accessors to ensure that the request body is not consumed by the SDK.Note: by using
_jsonand_formdirectly we can no longer distinguish between raw data payloads and payloads that were not cached on theRequestobject. The attribute is therefore omitted if the request body is not cached, since the endpoint may not have accessed it.The integration can still cause application hangs if middleware or handlers deprive the
receive()callable instead of using Starlette accessors. Reliance on the overly ambitious request body access is only eliminated for streamed spans (and only persists for errors with the change).test_request_body_data_does_not_scrub_pii_span_streaming()sincetest_formdata_request_body()already asserts that fields in the request body are not scrubbed.test_request_body_data_annotated_value_top_level_span_streaming()because the attribute is no longer set if the request body is not JSON or FormData.Issues
Reminders
tox -e linters.feat:,fix:,ref:,meta:)