[19.0][FIX] webservice: allow to return response object on OAuth2-configure…#138
Open
Ricardoalso wants to merge 1 commit into
Open
[19.0][FIX] webservice: allow to return response object on OAuth2-configure…#138Ricardoalso wants to merge 1 commit into
Ricardoalso wants to merge 1 commit into
Conversation
…d calls When sending exchanges through an OAuth2-configured webservice.backend, the request crashed with: TypeError: Session.request() got an unexpected keyword argument 'content_only' Stack trace pointed to webservice/components/request_adapter.py in BackendApplicationOAuth2RestRequestsAdapter._request, where content_only was forwarded to OAuth2Session.request(...)
Contributor
|
Hi @etobella, |
ivantodorovich
approved these changes
Jun 1, 2026
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.
…d calls
When sending exchanges through an OAuth2-configured webservice.backend, the request crashed with:
TypeError: Session.request() got an unexpected keyword argument 'content_only'Stack trace pointed to webservice/components/request_adapter.py in BackendApplicationOAuth2RestRequestsAdapter._request, where content_only was forwarded to OAuth2Session.request(...)
Also check #48
However
Defaulting content_only to True in "base.requests" seems wrong IMHO (current PR follows the same pattern)
content_only = kwargs.pop("content_only", True)The function returns two entirely different data types depending on a boolean flag. If content_only is True, it returns a bytes object (request.content). If content_only is False, it returns a requests.Response object (request).
Because it defaults to True, a standard call to an endpoint
self._request("GET", "/test")returns raw bytes instead of a typical HTTP response object. To access network metadata (such as headers or cookies), the caller must explicitly pass content_only=False. This violates the Principle of Least Astonishment.Open question⚠️
Should we keep the current compatibility contract for now (defaulting to bytes)? In this addon, the default behavior has historically been “bytes content”, and existing tests + doc. assert this.
Wanting raw content as the "normal" case and wanting the actual HTTP Response object as a "special context." is strange, but I don't have the full context in here. In global network programming, a Response object is the baseline rule 🤔
https://requests.readthedocs.io/en/latest/api/#main-interface