-
Notifications
You must be signed in to change notification settings - Fork 16.3k
Description
Apache Airflow version
main (development)
If "Other Airflow 2/3 version" selected, which one?
No response
What happened?
After updating to a build of Airflow that includes PR #57815, the FAB auth manager endpoint /auth/token started failing with a 500 error and the following exception in the API server logs:
RuntimeError: Working outside of application context.
...
File ".../airflow/providers/fab/auth_manager/security_manager/override.py", line XXX, in auth_type
return current_app.config["AUTH_TYPE"]
The call stack shows this originates from FABAuthManagerLogin.create_token(...), which reads auth_manager.security_manager.auth_type, and that auth_type property is implemented as return current_app.config["AUTH_TYPE"] in FabAirflowSecurityManagerOverride.
In PR #57815, the FastAPI routes in providers/fab/src/airflow/providers/fab/auth_manager/api_fastapi/routes/login.py were changed: the create_token, create_token_cli, and logout endpoints no longer wrap their logic in with get_application_builder(): .... Instead, they now call FABAuthManagerLogin.create_token(...) (or get_auth_manager().get_url_login()) directly, without setting up a Flask app context.
As a result, when these endpoints are hit via the API server, current_app is not bound and any access to current_app.config["AUTH_TYPE"] (and similar properties) fails with RuntimeError: Working outside of application context.
What you think should happen instead?
No response
How to reproduce
breeze start-airflowcurl --location 'http://localhost:28080/auth/token' \
--header 'Content-Type: application/json' \
--data '{"username":"admin","password":"admin"}'Operating System
macOS 15.5
Versions of Apache Airflow Providers
No response
Deployment
Other
Deployment details
Deployment: Breeze local dev environment (Docker Compose, airflow api-server with uvicorn)
Anything else?
No response
Are you willing to submit PR?
- Yes I am willing to submit a PR!
Code of Conduct
- I agree to follow this project's Code of Conduct