Skip to content

Commit

Permalink
fix(django): recreate response stream to prevent reading from empty r…
Browse files Browse the repository at this point in the history
…esponse body [backport 2.10] (#10208)

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.

(cherry picked from commit 20b8c2b)

## Checklist
- [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))

## Reviewer Checklist
- [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)
  • Loading branch information
wconti27 authored Aug 14, 2024
1 parent 63a5a04 commit 9c4fe6d
Show file tree
Hide file tree
Showing 27 changed files with 736 additions and 499 deletions.
72 changes: 72 additions & 0 deletions .riot/requirements/12e2ec4.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#
# This file is autogenerated by pip-compile with Python 3.12
# by the following command:
#
# pip-compile --allow-unsafe --no-annotate .riot/requirements/12e2ec4.in
#
arrow==1.3.0
asgiref==3.8.1
attrs==24.2.0
autobahn==24.4.2
automat==22.10.0
blessed==1.20.0
certifi==2024.7.4
cffi==1.17.0
channels==4.1.0
charset-normalizer==3.3.2
constantly==23.10.4
coverage[toml]==7.6.1
cryptography==43.0.0
daphne==4.1.2
django==4.2.15
django-picklefield==3.2
django-pylibmc==0.6.1
django-q==1.3.6
django-redis==4.5.0
hyperlink==21.0.0
hypothesis==6.45.0
idna==3.7
incremental==24.7.2
iniconfig==2.0.0
isodate==0.6.1
lxml==5.3.0
mock==5.1.0
opentracing==2.4.0
packaging==24.1
platformdirs==4.2.2
pluggy==1.5.0
psycopg==3.2.1
psycopg2-binary==2.9.9
pyasn1==0.6.0
pyasn1-modules==0.4.0
pycparser==2.22
pylibmc==1.6.3
pyopenssl==24.2.1
pytest==8.3.2
pytest-cov==5.0.0
pytest-django==3.10.0
pytest-mock==3.14.0
pytest-randomly==3.15.0
python-dateutil==2.9.0.post0
python-memcached==1.62
pytz==2024.1
redis==2.10.6
requests==2.32.3
requests-file==2.1.0
requests-toolbelt==1.0.0
service-identity==24.1.0
six==1.16.0
sortedcontainers==2.4.0
spyne==2.14.0
sqlparse==0.5.1
twisted[tls]==24.7.0
txaio==23.1.1
types-python-dateutil==2.9.0.20240316
typing-extensions==4.12.2
urllib3==2.2.2
wcwidth==0.2.13
zeep==4.2.1
zope-interface==7.0.1

# The following packages are considered to be unsafe in a requirements file:
setuptools==72.2.0
74 changes: 74 additions & 0 deletions .riot/requirements/138818b.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#
# This file is autogenerated by pip-compile with Python 3.10
# by the following command:
#
# pip-compile --allow-unsafe --no-annotate .riot/requirements/138818b.in
#
arrow==1.3.0
asgiref==3.8.1
attrs==24.2.0
autobahn==24.4.2
automat==22.10.0
blessed==1.20.0
certifi==2024.7.4
cffi==1.17.0
channels==4.1.0
charset-normalizer==3.3.2
constantly==23.10.4
coverage[toml]==7.6.1
cryptography==43.0.0
daphne==4.1.2
django==4.2.15
django-picklefield==3.2
django-pylibmc==0.6.1
django-q==1.3.6
django-redis==4.5.0
exceptiongroup==1.2.2
hyperlink==21.0.0
hypothesis==6.45.0
idna==3.7
incremental==24.7.2
iniconfig==2.0.0
isodate==0.6.1
lxml==5.3.0
mock==5.1.0
opentracing==2.4.0
packaging==24.1
platformdirs==4.2.2
pluggy==1.5.0
psycopg==3.2.1
psycopg2-binary==2.9.9
pyasn1==0.6.0
pyasn1-modules==0.4.0
pycparser==2.22
pylibmc==1.6.3
pyopenssl==24.2.1
pytest==8.3.2
pytest-cov==5.0.0
pytest-django==3.10.0
pytest-mock==3.14.0
pytest-randomly==3.15.0
python-dateutil==2.9.0.post0
python-memcached==1.62
pytz==2024.1
redis==2.10.6
requests==2.32.3
requests-file==2.1.0
requests-toolbelt==1.0.0
service-identity==24.1.0
six==1.16.0
sortedcontainers==2.4.0
spyne==2.14.0
sqlparse==0.5.1
tomli==2.0.1
twisted[tls]==24.7.0
txaio==23.1.1
types-python-dateutil==2.9.0.20240316
typing-extensions==4.12.2
urllib3==2.2.2
wcwidth==0.2.13
zeep==4.2.1
zope-interface==7.0.1

# The following packages are considered to be unsafe in a requirements file:
setuptools==72.2.0
34 changes: 21 additions & 13 deletions .riot/requirements/1692fb0.txt → .riot/requirements/15c2a69.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,66 +2,74 @@
# This file is autogenerated by pip-compile with Python 3.7
# by the following command:
#
# pip-compile --config=pyproject.toml --no-annotate --resolver=backtracking .riot/requirements/1692fb0.in
# pip-compile --allow-unsafe --no-annotate --resolver=backtracking .riot/requirements/15c2a69.in
#
arrow==1.2.3
asgiref==3.7.2
attrs==23.2.0
attrs==24.2.0
autobahn==23.1.2
automat==22.10.0
blessed==1.20.0
certifi==2024.2.2
cached-property==1.5.2
certifi==2024.7.4
cffi==1.15.1
channels==4.0.0
charset-normalizer==3.3.2
constantly==15.1.0
coverage[toml]==7.2.7
cryptography==42.0.3
cryptography==43.0.0
daphne==4.0.0
django==3.2.24
django-picklefield==3.1
django==3.2.25
django-picklefield==3.2
django-pylibmc==0.6.1
django-q==1.3.6
django-redis==4.5.0
exceptiongroup==1.2.0
exceptiongroup==1.2.2
hyperlink==21.0.0
hypothesis==6.45.0
idna==3.6
idna==3.7
importlib-metadata==6.7.0
incremental==22.10.0
iniconfig==2.0.0
isodate==0.6.1
lxml==5.3.0
mock==5.1.0
opentracing==2.4.0
packaging==23.2
packaging==24.0
platformdirs==4.0.0
pluggy==1.2.0
psycopg2-binary==2.9.9
pyasn1==0.5.1
pyasn1-modules==0.3.0
pycparser==2.21
pylibmc==1.6.3
pyopenssl==24.0.0
pyopenssl==24.2.1
pytest==7.4.4
pytest-cov==4.1.0
pytest-django==3.10.0
pytest-mock==3.11.1
pytest-randomly==3.12.0
python-dateutil==2.8.2
python-dateutil==2.9.0.post0
python-memcached==1.62
pytz==2024.1
redis==2.10.6
requests==2.31.0
requests-file==2.1.0
requests-toolbelt==1.0.0
service-identity==21.1.0
six==1.16.0
sortedcontainers==2.4.0
spyne==2.14.0
sqlparse==0.4.4
tomli==2.0.1
twisted[tls]==23.8.0
txaio==23.1.1
typing-extensions==4.7.1
urllib3==2.0.7
wcwidth==0.2.13
zeep==4.2.1
zipp==3.15.0
zope-interface==6.2
zope-interface==6.4.post2

# The following packages are considered to be unsafe in a requirements file:
# setuptools
setuptools==68.0.0
64 changes: 0 additions & 64 deletions .riot/requirements/164c9d2.txt

This file was deleted.

76 changes: 76 additions & 0 deletions .riot/requirements/173d698.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#
# This file is autogenerated by pip-compile with Python 3.8
# by the following command:
#
# pip-compile --allow-unsafe --no-annotate --resolver=backtracking .riot/requirements/173d698.in
#
arrow==1.3.0
asgiref==3.8.1
attrs==24.2.0
autobahn==23.1.2
automat==22.10.0
backports-zoneinfo==0.2.1
blessed==1.20.0
certifi==2024.7.4
cffi==1.17.0
channels==4.1.0
charset-normalizer==3.3.2
constantly==23.10.4
coverage[toml]==7.6.1
cryptography==43.0.0
daphne==4.1.2
django==4.2.15
django-picklefield==3.2
django-pylibmc==0.6.1
django-q==1.3.6
django-redis==4.5.0
exceptiongroup==1.2.2
hyperlink==21.0.0
hypothesis==6.45.0
idna==3.7
importlib-metadata==8.2.0
incremental==24.7.2
iniconfig==2.0.0
isodate==0.6.1
lxml==5.3.0
mock==5.1.0
opentracing==2.4.0
packaging==24.1
platformdirs==4.2.2
pluggy==1.5.0
psycopg2-binary==2.9.9
pyasn1==0.6.0
pyasn1-modules==0.4.0
pycparser==2.22
pylibmc==1.6.3
pyopenssl==24.2.1
pytest==8.3.2
pytest-cov==5.0.0
pytest-django==3.10.0
pytest-mock==3.14.0
pytest-randomly==3.15.0
python-dateutil==2.9.0.post0
python-memcached==1.62
pytz==2024.1
redis==2.10.6
requests==2.32.3
requests-file==2.1.0
requests-toolbelt==1.0.0
service-identity==24.1.0
six==1.16.0
sortedcontainers==2.4.0
spyne==2.14.0
sqlparse==0.5.1
tomli==2.0.1
twisted[tls]==24.7.0
txaio==23.1.1
types-python-dateutil==2.9.0.20240316
typing-extensions==4.12.2
urllib3==2.2.2
wcwidth==0.2.13
zeep==4.2.1
zipp==3.20.0
zope-interface==7.0.1

# The following packages are considered to be unsafe in a requirements file:
setuptools==72.2.0
Loading

0 comments on commit 9c4fe6d

Please sign in to comment.