Skip to content

Fix: Add session rollback to FAB find_user on error to prevent invali…#61374

Merged
vincbeck merged 4 commits into
apache:mainfrom
MonsterChenzhuo:fix1
Feb 5, 2026
Merged

Fix: Add session rollback to FAB find_user on error to prevent invali…#61374
vincbeck merged 4 commits into
apache:mainfrom
MonsterChenzhuo:fix1

Conversation

@MonsterChenzhuo

@MonsterChenzhuo MonsterChenzhuo commented Feb 3, 2026

Copy link
Copy Markdown
Contributor

Description

This PR adds exception handling and session rollback to the find_user method in FabAirflowSecurityManagerOverride.

Motivation and Context

Currently, the find_user method in the FAB security manager override only catches MultipleResultsFound exceptions. If any other exception occurs during the database query (e.g., a temporary database disconnection, query timeout, or an _invalid_transaction state), the session is not rolled back.

This leaves the SQLAlchemy session in a broken/dirty state. Since sessions are often reused in the worker process, subsequent requests (like login attempts) fail continuously with errors like:
img_v3_02uk_501b3c4c-211b-4c18-a181-fb5f32b4ba9g

@boring-cyborg

boring-cyborg Bot commented Feb 3, 2026

Copy link
Copy Markdown

Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide (https://github.com/apache/airflow/blob/main/contributing-docs/README.rst)
Here are some useful points:

  • Pay attention to the quality of your code (ruff, mypy and type annotations). Our prek-hooks will help you with that.
  • In case of a new feature add useful documentation (in docstrings or in docs/ directory). Adding a new operator? Check this short guide Consider adding an example DAG that shows how users should use it.
  • Consider using Breeze environment for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
  • Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
  • Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
    Apache Airflow is a community-driven project and together we are making it better 🚀.
    In case of doubts contact the developers at:
    Mailing List: dev@airflow.apache.org
    Slack: https://s.apache.org/airflow-slack

Comment thread providers/fab/src/airflow/providers/fab/auth_manager/security_manager/override.py Outdated
Comment thread providers/fab/src/airflow/providers/fab/auth_manager/security_manager/override.py Outdated
@vincbeck vincbeck merged commit 0e66a21 into apache:main Feb 5, 2026
86 checks passed
@boring-cyborg

boring-cyborg Bot commented Feb 5, 2026

Copy link
Copy Markdown

Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions.

jhgoebbert pushed a commit to jhgoebbert/airflow_Owen-CH-Leung that referenced this pull request Feb 8, 2026
Subham-KRLX pushed a commit to Subham-KRLX/airflow that referenced this pull request Mar 4, 2026
Ankurdeewan pushed a commit to Ankurdeewan/airflow that referenced this pull request Mar 15, 2026
radhwene pushed a commit to radhwene/airflow that referenced this pull request Mar 21, 2026
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