barunpuri opened a new issue, #64151:
URL: https://github.com/apache/airflow/issues/64151
### Apache Airflow Provider(s)
fab
### Versions of Apache Airflow Providers
/opt/airflow$ pip freeze | grep providers
apache-airflow-providers-amazon==9.22.0
apache-airflow-providers-celery==3.17.0
apache-airflow-providers-cncf-kubernetes==10.13.0
apache-airflow-providers-common-compat==1.14.0
apache-airflow-providers-common-io==1.7.1
apache-airflow-providers-common-messaging==2.0.2
apache-airflow-providers-common-sql==1.32.0
apache-airflow-providers-docker==4.5.2
apache-airflow-providers-elasticsearch==6.5.0
apache-airflow-providers-fab==3.5.0
apache-airflow-providers-ftp==3.14.1
apache-airflow-providers-git==0.2.4
apache-airflow-providers-google==20.0.0
apache-airflow-providers-grpc==3.9.2
apache-airflow-providers-hashicorp==4.5.0
apache-airflow-providers-http==6.0.0
apache-airflow-providers-microsoft-azure==13.0.0
apache-airflow-providers-mysql==6.5.0
apache-airflow-providers-odbc==4.12.0
apache-airflow-providers-openlineage==2.11.0
apache-airflow-providers-postgres==6.6.0
apache-airflow-providers-redis==4.4.2
apache-airflow-providers-sendgrid==4.2.1
apache-airflow-providers-sftp==5.7.0
apache-airflow-providers-slack==9.7.0
apache-airflow-providers-smtp==2.4.2
apache-airflow-providers-snowflake==6.10.0
apache-airflow-providers-ssh==4.3.1
apache-airflow-providers-standard==1.12.0
### Apache Airflow version
3.1.8
### Operating System
Debian GNU/Linux 12 (bookworm)
### Deployment
Official Apache Airflow Helm Chart
### Deployment details
Use apache/airflow:3.1.8-python3.12 image
### What happened
When running Airflow 3.1.8 with `apache-airflow-providers-fab==3.5.0` (using
Python 3.12), the application fails to handle login requests and throws a 500
Internal Server Error.
Looking at the traceback, it crashes with
`airflow.exceptions.AirflowException: AppBuilder is not initialized.` during
the FastAPI endpoint execution (`/auth/token` or login routes).
I think the error occurs because `auth_manager.register_views()` is called,
which in turn calls `self.security_manager`. However, because the `AppBuilder`
initialization context is not yet fully completed, the `security_manager`
property raises the exception.
**Traceback snippet:**
```python
# ... (previous traceback omitted for brevity)
File
"/home/airflow/.local/lib/python3.12/site-packages/airflow/providers/fab/auth_manager/cli_commands/utils.py",
line 45, in init_appbuilder
init_appbuilder(app, enable_plugins=False)
File
"/home/airflow/.local/lib/python3.12/site-packages/airflow/providers/fab/www/extensions/init_appbuilder.py",
line 606, in init_appbuilder
return AirflowAppBuilder(
File
"/home/airflow/.local/lib/python3.12/site-packages/airflow/providers/fab/www/extensions/init_appbuilder.py",
line 159, in init_app
self.init_app(app, session)
File
"/home/airflow/.local/lib/python3.12/site-packages/airflow/providers/fab/www/extensions/init_appbuilder.py",
line 215, in _add_admin_views
self._add_admin_views()
File
"/home/airflow/.local/lib/python3.12/site-packages/airflow/providers/fab/www/extensions/init_appbuilder.py",
line 311, in register_views
auth_manager.register_views()
File
"/home/airflow/.local/lib/python3.12/site-packages/airflow/providers/fab/auth_manager/fab_auth_manager.py",
line 599, in register_views
self.security_manager.register_views()
File "/usr/python/lib/python3.12/functools.py", line 998, in __get__
val = self.func(instance)
File
"/home/airflow/.local/lib/python3.12/site-packages/airflow/providers/fab/auth_manager/fab_auth_manager.py",
line 578, in security_manager
raise AirflowException("AppBuilder is not initialized.")
airflow.exceptions.AirflowException: AppBuilder is not initialized.
```
Workaround:
I found that setting `AIRFLOW__FAB__UPDATE_FAB_PERMS=False` bypasses this
issue and allows the server to run successfully.
### What you think should happen instead
The FastAPI application should initialize successfully and serve auth
requests without crashing, even when the default configuration
`update_fab_perms = True` is used.
The internal startup sequence should be fixed so that the `AppBuilder` is
completely instantiated and attached to the context *before* the Auth Manager
attempts to access `self.security_manager` to sync roles or register views.
### How to reproduce
1. Set up an environment with Airflow 3.1.8 and Python 3.12.
2. Install the FAB provider version 3.5.0: `pip install
apache-airflow-providers-fab==3.5.0`
3. Ensure the default configuration for FAB permissions is active (do NOT
set `update_fab_perms = False`).
4. Start the Airflow webserver (FastAPI application).
5. Attempt to hit the login route or `/auth/token` endpoint.
6. Observe the `AppBuilder is not initialized` exception in the api-server
logs.
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [x] I agree to follow this project's [Code of
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
--
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]