Copilot commented on code in PR #64908:
URL: https://github.com/apache/airflow/pull/64908#discussion_r3066472668
##########
providers/fab/src/airflow/providers/fab/auth_manager/api_fastapi/routes/login.py:
##########
@@ -49,10 +49,9 @@ def _get_flask_app():
),
)
if not auth_manager.flask_app:
- raise HTTPException(
- status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
- detail="Flask app is not initialized. Check that FabAuthManager
started up correctly.",
- )
+ from airflow.providers.fab.www.app import create_app
+
+ auth_manager.flask_app = create_app(enable_plugins=False)
Review Comment:
`create_app(...)` can raise (e.g., misconfiguration, import-time failures).
With the old behavior, callers got a clear `HTTPException` detail; now failures
will bubble up and likely become a generic 500 without a helpful message.
Consider catching exceptions from `create_app(...)`, logging the underlying
error, and re-raising an `HTTPException(status_code=500, detail=...)` so
debugging remains straightforward.
##########
providers/fab/src/airflow/providers/fab/auth_manager/api_fastapi/routes/login.py:
##########
@@ -49,10 +49,9 @@ def _get_flask_app():
),
)
if not auth_manager.flask_app:
- raise HTTPException(
- status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
- detail="Flask app is not initialized. Check that FabAuthManager
started up correctly.",
- )
+ from airflow.providers.fab.www.app import create_app
+
+ auth_manager.flask_app = create_app(enable_plugins=False)
Review Comment:
This lazy init is not thread-safe: under concurrent requests, multiple
workers/threads can enter this branch and run `create_app(...)` more than once,
potentially causing duplicated initialization side-effects (registrations,
globals, logging handlers, etc.). Consider guarding initialization with a lock
(or another one-time init mechanism) around the `if not auth_manager.flask_app`
/ assignment to ensure only one `create_app(...)` executes per process.
--
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]