Skip to content

Conversation

@vincbeck
Copy link
Contributor

A small Flask application is embedded in fastapi application using WSGIMiddleware. This flask application can throw some exceptions. These exceptions are then propagated to the fastapi application. Since these exceptions are specific to Flask and not handled on the fastapi side, it results as a 500.

This PR does two things:

  • On Flask side, it convert these exceptions to JSON so that fastapi can parse them and understand them
  • On fastapi side, through a middleware, if I receive an exception as JSON, I convert it to a fastapi exception

^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in newsfragments.

@vincbeck vincbeck merged commit 5ff411b into apache:main Jan 14, 2025
64 checks passed
@vincbeck vincbeck deleted the vincbeck/flask_exceptions branch January 14, 2025 15:31
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