You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This means it isn't safe to call json() on the response and keep the response unchanged. I can see the argument that this is a bug in requests, but for the moment there is now a subtle side effect introduced just by attempting logging - the implicit assumption is response won't change. I can imagine a less than ideal option would be to copy the response before trying to json()?
The text was updated successfully, but these errors were encountered:
Hello,
In v2.40, new helpers were introduced that can log various requests and responses.
One such helper, response_log() tries to jsonify a response instance (
google-auth-library-python/google/auth/_helpers.py
Line 477 in 56b4d3b
The issue with this is it causes the response instance state to change. Called via https://github.com/psf/requests/blob/c65c780849563c891f35ffc98d3198b71011c012/src/requests/models.py#L965, we can retrieve content which causes _content_consumed to change to True, even though the JSON decode failed.
This means it isn't safe to call json() on the response and keep the response unchanged. I can see the argument that this is a bug in requests, but for the moment there is now a subtle side effect introduced just by attempting logging - the implicit assumption is response won't change. I can imagine a less than ideal option would be to copy the response before trying to json()?
The text was updated successfully, but these errors were encountered: