Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: restore AttributeRemovedError for resp.body #2361

Merged
merged 3 commits into from
Oct 9, 2024

Conversation

vytas7
Copy link
Member

@vytas7 vytas7 commented Oct 9, 2024

The blocked resp.body property was introduced in #2090, and then removed later in the 4.0( cycle by oversight.

It is useful to have it, since otherwise setting resp.body in legacy code silently does nothing, and it is hard to understand what is going on.

Example when using swagger-ui-py (unfortunately, it needs to be updated):

2024-10-09 13:44:20 [FALCON] [ERROR] GET /api/doc => Traceback (most recent call last):
  File "<venv>/lib/python3.8/site-packages/falcon/app.py", line 440, in __call__
    responder(req, resp, **params)
  File "<venv>/lib/python3.8/site-packages/swagger_ui/handlers/falcon.py", line 19, in on_get
    resp.body = doc.doc_html
  File "<venv>/lib/python3.8/site-packages/falcon/response.py", line 221, in body
    raise AttributeRemovedError(
falcon.util.deprecation.AttributeRemovedError: The body attribute is no longer supported. Please use the text attribute instead.

(With 4.0.0b1, the page is completely blank, and nothing is logged on the server side either.)

Copy link

codecov bot commented Oct 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (25027b2) to head (35b4af7).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##            master     #2361    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files           64        64            
  Lines         7721      7727     +6     
  Branches      1269      1073   -196     
==========================================
+ Hits          7721      7727     +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@vytas7 vytas7 requested review from kgriffs and CaselIT October 9, 2024 11:44
CaselIT
CaselIT previously approved these changes Oct 9, 2024
Copy link
Member

@CaselIT CaselIT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this wasn't in 3.x?

@vytas7
Copy link
Member Author

vytas7 commented Oct 9, 2024

The attribute was already deprecated in 3.x, but resp.body raising AttributeRemovedError has never been part of a stable release.

@vytas7
Copy link
Member Author

vytas7 commented Oct 9, 2024

I am going to disable the Firefox gate for now. I haven't found the reason yet, but I suspect something is not working correctly with geckodriver on Linux and the newest Firefox 131.0. I won't have the bandwidth to dig into this.

Locally, it works for me, but I cannot make the browser headless anymore, it always pops up. In the gate, 1/2 tests fail.

@vytas7 vytas7 requested a review from CaselIT October 9, 2024 12:25
@vytas7 vytas7 merged commit 8c7b5c0 into falconry:master Oct 9, 2024
31 checks passed
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.

2 participants