Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(django): recreate response stream to prevent reading from empty response body [backport 2.10] #10208

Merged
merged 2 commits into from
Aug 14, 2024

Conversation

wconti27
Copy link
Contributor

@wconti27 wconti27 commented Aug 13, 2024

Fixes customer escalation. Customer was using the Spyne library with Django and making SOAP requests towards it. The problem was found to be that Django integration was reading the response body to set some span tags. However, later in the callstack, Spyne also tries to read the response body (now empty since the stream was fully read). This PR copies/recreates the response body to prevent this error.

(cherry picked from commit 20b8c2b)

Checklist

  • PR author has checked that all the criteria below are met
  • The PR description includes an overview of the change
  • The PR description articulates the motivation for the change
  • The change includes tests OR the PR description describes a testing strategy
  • The PR description notes risks associated with the change, if any
  • Newly-added code is easy to change
  • The change follows the library release note guidelines
  • The change includes or references documentation updates if necessary
  • Backport labels are set (if applicable)

Reviewer Checklist

  • Reviewer has checked that all the criteria below are met
  • Title is accurate
  • All changes are related to the pull request's stated goal
  • Avoids breaking API changes
  • Testing strategy adequately addresses listed risks
  • Newly-added code is easy to change
  • Release note makes sense to a user of the library
  • If necessary, author has acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment
  • Backport labels are set in a manner that is consistent with the release branch maintenance policy

…esponse body (#10137)

Fixes customer escalation. Customer was using the [Spyne
library](https://github.com/arskom/spyne) with Django and making SOAP
requests towards it. The problem was found to be that Django integration
was reading the response body to set some span tags. However, later in
the callstack, Spyne also tries to read the response body (now empty
since the stream was fully read). This PR copies/recreates the response
body to prevent this error.

- [x] PR author has checked that all the criteria below are met
- The PR description includes an overview of the change
- The PR description articulates the motivation for the change
- The change includes tests OR the PR description describes a testing
strategy
- The PR description notes risks associated with the change, if any
- Newly-added code is easy to change
- The change follows the [library release note
guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
- The change includes or references documentation updates if necessary
- Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))

- [x] Reviewer has checked that all the criteria below are met
- Title is accurate
- All changes are related to the pull request's stated goal
- Avoids breaking
[API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
changes
- Testing strategy adequately addresses listed risks
- Newly-added code is easy to change
- Release note makes sense to a user of the library
- If necessary, author has acknowledged and discussed the performance
implications of this PR as reported in the benchmarks PR comment
- Backport labels are set in a manner that is consistent with the
[release branch maintenance
policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)

(cherry picked from commit 20b8c2b)
@datadog-dd-trace-py-rkomorn
Copy link

datadog-dd-trace-py-rkomorn bot commented Aug 13, 2024

Datadog Report

Branch report: backport-10137-to-2.10
Commit report: bc492bd
Test service: dd-trace-py

✅ 0 Failed, 175966 Passed, 1571 Skipped, 12h 49m 49.17s Total duration (44m 44.8s time saved)
⌛ 17 Performance Regressions

⌛ Performance Regressions vs Default Branch (17)

This report shows up to 5 performance regressions.

  • test_distributed_tracing_disabled_via_env_var - test_distributed_tracing.py 4.05s (+3.36s, +494%) - Details
  • test_pymysql_dbm_propagation_enabled - test_pymysql.py 3.6s (+2.97s, +475%) - Details
  • test_import_patch_unpatch_patch - test_pymysql_patch.py 4.37s (+3.85s, +738%)
  • test_operation_name_v0 - test_client.py 2.83s (+2.26s, +402%) - Details
  • test_user_specified_service_v0 - test_client.py 2.94s (+2.38s, +421%) - Details

@pr-commenter
Copy link

pr-commenter bot commented Aug 13, 2024

Benchmarks

Benchmark execution time: 2024-08-13 20:24:10

Comparing candidate commit a3d1d67 in PR branch backport-10137-to-2.10 with baseline commit 63a5a04 in branch 2.10.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 221 metrics, 9 unstable metrics.

@wconti27 wconti27 enabled auto-merge (squash) August 14, 2024 14:29
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 12.24490% with 86 lines in your changes missing coverage. Please review.

Project coverage is 10.18%. Comparing base (63a5a04) to head (bc492bd).

Files Patch % Lines
tests/contrib/django/soap/models.py 0.00% 28 Missing ⚠️
tests/contrib/django/test_django_wsgi.py 0.00% 26 Missing ⚠️
tests/contrib/django/soap/services.py 0.00% 20 Missing ⚠️
tests/contrib/django/utils.py 0.00% 8 Missing ⚠️
tests/contrib/django/soap/apps.py 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             2.10   #10208      +/-   ##
==========================================
- Coverage   11.95%   10.18%   -1.78%     
==========================================
  Files        1309     1313       +4     
  Lines      124979   125071      +92     
==========================================
- Hits        14943    12736    -2207     
- Misses     110036   112335    +2299     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@wconti27 wconti27 merged commit 9c4fe6d into 2.10 Aug 14, 2024
190 of 207 checks passed
@wconti27 wconti27 deleted the backport-10137-to-2.10 branch August 14, 2024 14:44
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.

4 participants