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

Flask-RESTful will fail when Flask deprecates propagate_exceptions: Fix #962

Conversation

transreductionist
Copy link
Contributor

@transreductionist transreductionist commented Mar 19, 2023

Handle the deprecation of Flask's propagate_exceptions

Overview of the Issue in Flask-RESTful

Flasks app.propagate_exceptions will be deprecated in the next release, and although the Flask developers don't have a release date, given their release history it may be sooner rather than later. If it is deprecated Flask-RESTful will throw an exception in flask_restul.__init__ in the handle_errors method. This is the only place in Flask-RESTful where this
attribute is accessed.

This pull request addresses the need to fix this issue in Flask-RESTful. Along with the fix I cleaned up that area of the code a bit, and made a few minor style changes, e.g., fixing a typo, removing an extra line feed, etc. Unit tests were added and pass.

Currently in Flask, if app.propagate_exceptions is set to True then the exceptions are re-raised rather than being handled by the app’s error handlers. When app.propagate_exceptions is deprecated app.config['PROPAGATE_EXCEPTIONS'] may be used in its place. Additionally, if app.propagate_exceptions is None (default value), then a sensible value should be substituted.

Relevant Flask Documentation

Flask Config Docs

Relevant Flask Pull Requests

#4716: deprecate most config attributes (fixed by #4722)
#4722: deprecate most config attributes (merged)

@transreductionist
Copy link
Contributor Author

transreductionist commented Mar 21, 2023

Looking at Flask 2.3 the propagate_exceptions method, which chose a sensible value if the propagate_exceptions is None, has been removed (deprecated). Handling the case where propagate_exceptions is None has been included here.

@transreductionist transreductionist changed the title Fix deprecation of flask propagate exceptions Flask-RESTful will fail when Flask deprecates propagate_exceptions: Fix Mar 23, 2023
@joshfriend joshfriend merged commit b52b188 into flask-restful:master May 21, 2023
@joshfriend
Copy link
Member

well that was an adventure... there's no CI for the project anymore because Travis CI went non-free a long time ago, trying to run tests doesn't work well anymore because none of the python versions in the project setup support Apple M1/M2 macs, and setuptools no longer supports pypi publishing (so i had to hack it with twine).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants