You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "barunpuri (via GitHub)" <gi...@apache.org> on 2026/03/24 09:46:45 UTC
[I] AirflowException "AppBuilder is not initialized" on startup with FAB provider 3.5.0 [airflow]
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: commits-unsubscribe@airflow.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] AirflowException "AppBuilder is not initialized" on startup with FAB provider 3.5.0 [airflow]
Posted by "sa1 (via GitHub)" <gi...@apache.org>.
sa1 commented on issue #64151:
URL: https://github.com/apache/airflow/issues/64151#issuecomment-4148368018
I have the same setup - airflow 3.1.8, python 3.12, fab 3.5.0 and I'm getting the exact same error (same traceback) and behaviour(some calls to /auth/token succeed, others fail). Hope to test the against provider 3.6 soon, and then against the airflow 3.2.0
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] AirflowException "AppBuilder is not initialized" on startup with FAB provider 3.5.0 [airflow]
Posted by "jscheffl (via GitHub)" <gi...@apache.org>.
jscheffl closed issue #64151: AirflowException "AppBuilder is not initialized" on startup with FAB provider 3.5.0
URL: https://github.com/apache/airflow/issues/64151
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] AirflowException "AppBuilder is not initialized" on startup with FAB provider 3.5.0 [airflow]
Posted by "eladkal (via GitHub)" <gi...@apache.org>.
eladkal commented on issue #64151:
URL: https://github.com/apache/airflow/issues/64151#issuecomment-4118026670
cc @vincbeck
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] AirflowException "AppBuilder is not initialized" on startup with FAB provider 3.5.0 [airflow]
Posted by "barunpuri (via GitHub)" <gi...@apache.org>.
barunpuri commented on issue #64151:
URL: https://github.com/apache/airflow/issues/64151#issuecomment-4118723635
> What I mean by that, since I tested against main, I was wondering if it has been fixed since the last release. It appears not (I might be wrong).
I tested with apache/airflow:3.1.8-python3.12 image + fab==3.5.0
> Are you sure of your setup?
I'm sorry. I should have added more explanation.
Our environment has 2 api servers and 3 workers. On this environment, I made 20+ tasks which issues a jwt token with `/auth/token` api. Some tasks succeed but some are failed. In that time tasks retruns 500 internal errer and api-server logging AppBuilder is not initialized error.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] AirflowException "AppBuilder is not initialized" on startup with FAB provider 3.5.0 [airflow]
Posted by "kalluripradeep (via GitHub)" <gi...@apache.org>.
kalluripradeep commented on issue #64151:
URL: https://github.com/apache/airflow/issues/64151#issuecomment-4150865970
I've investigated this behavior and just opened a PR with a fix: #64418
Root Cause: The AppBuilder is not initialized error during the /auth/token requests happens because the FastAPI endpoints were using the get_application_builder() context manager. This method was designed for offline CLI commands, meaning it bootstraps a brand new Flask and AppBuilder environment on every single request and mutates the global FabAuthManager singleton.
When this happens, the newly created AppBuilder wipes the auth_manager.security_manager @cached_property. Under minimal concurrency, this cached property gets caught mid-evaluation or deleted entirely after the context ends, causing the 500 error. Setting UPDATE_FAB_PERMS=False bypasses the crash only because it skips early requests to the deleted security_manager cache during init_flask_resources().
The Fix: I've updated the FabAuthManager to persistently store its primary Flask instance created during get_fastapi_app(). The /auth/token endpoints now cleanly yield auth_manager.flask_app.app_context() instead of generating volatile CLI setups, completely preventing the race condition.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] AirflowException "AppBuilder is not initialized" on startup with FAB provider 3.5.0 [airflow]
Posted by "vincbeck (via GitHub)" <gi...@apache.org>.
vincbeck commented on issue #64151:
URL: https://github.com/apache/airflow/issues/64151#issuecomment-4118561036
I tested it against main and I could not reproduce it. When I look at the history I cannot see something recent related to this issue either. What I mean by that, since I tested against main, I was wondering if it has been fixed since the last release. It appears not (I might be wrong). Are you sure of your setup @barunpuri? Provider release is happening as we speak, if you confirm your setup is correct, you could test the new release candidate to see if it had been fixed with the new version
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org