Skip to content

[19.0][FIX] webservice: allow to return response object on OAuth2-configure…#138

Merged
OCA-git-bot merged 1 commit into
OCA:19.0from
camptocamp:web-api_content_only
Jul 1, 2026
Merged

[19.0][FIX] webservice: allow to return response object on OAuth2-configure…#138
OCA-git-bot merged 1 commit into
OCA:19.0from
camptocamp:web-api_content_only

Conversation

@Ricardoalso

@Ricardoalso Ricardoalso commented May 29, 2026

Copy link
Copy Markdown

…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 / Open Concern

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 🤔

All of Requests’ functionality can be accessed by these 7 methods. They all return an instance of the Response object.

https://requests.readthedocs.io/en/latest/api/#main-interface

…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(...)
@OCA-git-bot

Copy link
Copy Markdown
Contributor

Hi @etobella,
some modules you are maintaining are being modified, check this out!

@Ricardoalso Ricardoalso changed the title [FIX] webservice: allow to return response object on OAuth2-configure… [19.0][FIX] webservice: allow to return response object on OAuth2-configure… May 29, 2026
@Ricardoalso Ricardoalso marked this pull request as draft May 29, 2026 10:00
@Ricardoalso Ricardoalso marked this pull request as ready for review May 29, 2026 10:25
@simahawk

simahawk commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

/ocabot merge patch

@Ricardoalso can you pls backport it to 18?

@OCA-git-bot

Copy link
Copy Markdown
Contributor

This PR looks fantastic, let's merge it!
Prepared branch 19.0-ocabot-merge-pr-138-by-simahawk-bump-patch, awaiting test results.

@OCA-git-bot

Copy link
Copy Markdown
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

@OCA-git-bot OCA-git-bot merged commit cc3b74b into OCA:19.0 Jul 1, 2026
7 checks passed
@OCA-git-bot

Copy link
Copy Markdown
Contributor

Congratulations, your PR was merged at ad92c69. Thanks a lot for contributing to OCA. ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants