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

Namespace error handlers broken when propagate_exceptions=True #285

Closed
mjreiss opened this issue Feb 20, 2021 · 0 comments
Closed

Namespace error handlers broken when propagate_exceptions=True #285

mjreiss opened this issue Feb 20, 2021 · 0 comments
Labels
bug Something isn't working

Comments

@mjreiss
Copy link
Contributor

mjreiss commented Feb 20, 2021

Details

When an errorhandler is registered on a namespace, and PROPAGATE_EXCEPTIONS is set to True in the Flask app, then the namespace handler will not catch the exceptions. It looks like this is due to the handle_error function not checking the error handlers that exist in any child classes.

Code

api.py:653

if (
    not isinstance(e, HTTPException)
    and current_app.propagate_exceptions
    and not isinstance(e, tuple(self.error_handlers.keys()))
):

Should check for potential error handlers in the class and child classes:

if (
    not isinstance(e, HTTPException)
    and current_app.propagate_exceptions
    and not isinstance(e, tuple(self._own_and_child_error_handlers.keys()))
):

Repro Steps (if applicable)

  1. Set propagate_exceptions=True in the app
  2. Create a namespace, and register it to the API
  3. Add a @namespace.errorhandler function
  4. Raise error in a route, which won't get caught by namespace's error handler

Expected Behavior

Error handler defined on a namespace should still catch exceptions when propagate_exceptions is True.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant