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 (#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)
  • Loading branch information
wconti27 committed Aug 13, 2024
1 parent 63a5a04 commit a3d1d67
Show file tree
Hide file tree
Showing 18 changed files with 699 additions and 7 deletions.
77 changes: 77 additions & 0 deletions .riot/requirements/11065bb.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# 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/11065bb.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-configurations==2.5.1
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
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[testing]==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.1.0
73 changes: 73 additions & 0 deletions .riot/requirements/1d3001d.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# pip-compile --allow-unsafe --no-annotate .riot/requirements/1d3001d.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-configurations==2.5.1
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.2.2
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[testing]==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.3.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.1.0
73 changes: 73 additions & 0 deletions .riot/requirements/1ef9f39.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#
# This file is autogenerated by pip-compile with Python 3.12
# by the following command:
#
# pip-compile --allow-unsafe --no-annotate .riot/requirements/1ef9f39.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-configurations==2.5.1
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[testing]==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.1.0
77 changes: 77 additions & 0 deletions .riot/requirements/1fe2c8e.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#
# 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/1fe2c8e.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-configurations==2.5.1
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[testing]==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.1.0
76 changes: 76 additions & 0 deletions .riot/requirements/2848d2c.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.7
# by the following command:
#
# pip-compile --allow-unsafe --no-annotate --resolver=backtracking .riot/requirements/2848d2c.in
#
arrow==1.2.3
asgiref==3.7.2
attrs==24.2.0
autobahn==23.1.2
automat==22.10.0
blessed==1.20.0
cached-property==1.5.2
certifi==2024.7.4
cffi==1.15.1
channels==3.0.5
charset-normalizer==3.3.2
constantly==15.1.0
coverage[toml]==7.2.7
cryptography==43.0.0
daphne==3.0.2
django==3.2.25
django-configurations==2.4.2
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==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==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.2.1
pytest==7.4.4
pytest-cov==4.1.0
pytest-django[testing]==3.10.0
pytest-mock==3.11.1
pytest-randomly==3.12.0
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.4.post2

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

0 comments on commit a3d1d67

Please sign in to comment.