deepujain opened a new pull request, #64375: URL: https://github.com/apache/airflow/pull/64375
## Summary `airflow users reset-password` in Airflow 2.11.2 can fail because the command looks up the user in one Flask app context and then resets the password in a different one. This change keeps the lookup and password reset inside the same application builder context so the security manager uses a fully initialized SQLAlchemy extension. ## Changes - **`providers/fab/src/airflow/providers/fab/auth_manager/cli_commands/user_command.py`** -- refactored user lookup so `user_reset_password()` resolves the user and performs the password reset inside a single `get_application_builder()` context. - **`providers/fab/tests/unit/fab/auth_manager/cli_commands/test_user_command.py`** -- added a regression test that verifies `user_reset_password()` only opens one application builder context while resetting the password. ## Test plan - [x] `uv run --project /Users/dejain/nvidia/oss/airflow-63830/providers/fab pytest /Users/dejain/nvidia/oss/airflow-63830/providers/fab/tests/unit/fab/auth_manager/cli_commands/test_user_command.py -k 'reset_user_password' -xvs` - [x] `ruff check /Users/dejain/nvidia/oss/airflow-63830/providers/fab/src/airflow/providers/fab/auth_manager/cli_commands/user_command.py /Users/dejain/nvidia/oss/airflow-63830/providers/fab/tests/unit/fab/auth_manager/cli_commands/test_user_command.py` - [x] `ruff format --check /Users/dejain/nvidia/oss/airflow-63830/providers/fab/src/airflow/providers/fab/auth_manager/cli_commands/user_command.py /Users/dejain/nvidia/oss/airflow-63830/providers/fab/tests/unit/fab/auth_manager/cli_commands/test_user_command.py` - [ ] CI passes (ruff, mypy, pytest) ## Evidence it works - The targeted reset-password unit test selection passed locally with `3 passed, 22 deselected`. - The new regression test asserts that `user_reset_password()` uses a single application builder context, which matches the root cause described in the issue discussion. Fixes #63830 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
