Apache Airflow Provider(s)
fab
Versions of Apache Airflow Providers
apache-airflow-providers-fab==3.1.1
full-list
apache-airflow-providers-amazon==9.19.0
apache-airflow-providers-celery==3.15.0
apache-airflow-providers-cncf-kubernetes==10.12.0
apache-airflow-providers-common-compat==1.11.0
apache-airflow-providers-common-io==1.7.0
apache-airflow-providers-common-messaging==2.0.1
apache-airflow-providers-common-sql==1.30.2
apache-airflow-providers-docker==4.5.1
apache-airflow-providers-elasticsearch==6.4.2
apache-airflow-providers-fab==3.1.1
apache-airflow-providers-ftp==3.14.0
apache-airflow-providers-git==0.2.0
apache-airflow-providers-google==19.3.0
apache-airflow-providers-grpc==3.9.1
apache-airflow-providers-hashicorp==4.4.1
apache-airflow-providers-http==5.6.2
apache-airflow-providers-microsoft-azure==12.10.1
apache-airflow-providers-mysql==6.4.0
apache-airflow-providers-odbc==4.11.0
apache-airflow-providers-openlineage==2.9.2
apache-airflow-providers-postgres==6.5.1
apache-airflow-providers-redis==4.4.1
apache-airflow-providers-sendgrid==4.2.0
apache-airflow-providers-sftp==5.5.1
apache-airflow-providers-slack==9.6.1
apache-airflow-providers-smtp==2.4.1
apache-airflow-providers-snowflake==6.8.1
apache-airflow-providers-ssh==4.2.1
apache-airflow-providers-standard==1.10.2
Apache Airflow version
3.1.6
Operating System
Debian GNU/Linux 12 (bookworm)
Deployment
Official Apache Airflow Helm Chart
Deployment details
No response
What happened
Hi, apologies if this is a duplicate or if I've misunderstood the code - I searched but couldn't find an existing issue.
When sending concurrent requests to /auth/token, intermittent 500 errors occur with:
AttributeError: 'AirflowAppBuilder' object has no attribute 'sm'
File ".../airflow/providers/fab/www/extensions/init_appbuilder.py", line 548, in _add_permission
if hasattr(self.sm, "add_permissions_view"):
In my case, this is easily reproducible - even just 2 concurrent requests can trigger the error.
Suspected cause:
It appears that create_auth_manager() in api_fastapi/app.py creates a new instance on every call without checking for an existing one, which may cause race conditions when multiple requests initialize the auth manager simultaneously.
What you think should happen instead
Concurrent requests to /auth/token should not cause server errors.
If my analysis is correct, create_auth_manager() is not thread-safe and concurrent calls cause issues.
Looking at _AuthManagerState and get_auth_manager(), I assume a singleton pattern is intended, but I'm not entirely sure. Either way, it seems like proper synchronization (e.g., double-checked locking) is needed.
How to reproduce
- Start Airflow with FAB auth manager
- Send 2+ concurrent POST requests to
/auth/token
(example python script)
import asyncio
import httpx
async def main():
async with httpx.AsyncClient(timeout=30.0) as client:
tasks = [
client.post(
"http://localhost:8080/auth/token",
json={"username": "admin", "password": "admin"},
)
for _ in range(2)
]
results = await asyncio.gather(*tasks, return_exceptions=True)
for i, r in enumerate(results):
if isinstance(r, Exception):
print(f"Request {i}: Exception - {r}")
else:
print(f"Request {i}: {r.status_code} - {r.text[:200] if r.status_code != 201 else 'OK'}")
asyncio.run(main())
Note: Other endpoints like /api/v2/dags work fine under concurrent load.
Anything else
This issue started occurring after upgrading to recent versions.
(airflow: 3.0.6 ->3.1.6, fab: 2.4.1 -> 3.1.1)
I suspect it may be related to recent refactoring (#59772, #59953), but I'm not entirely certain.
Happy to provide more details or test any fixes.
Are you willing to submit PR?
Code of Conduct
Apache Airflow Provider(s)
fab
Versions of Apache Airflow Providers
apache-airflow-providers-fab==3.1.1
full-list
Apache Airflow version
3.1.6
Operating System
Debian GNU/Linux 12 (bookworm)
Deployment
Official Apache Airflow Helm Chart
Deployment details
No response
What happened
Hi, apologies if this is a duplicate or if I've misunderstood the code - I searched but couldn't find an existing issue.
When sending concurrent requests to
/auth/token, intermittent 500 errors occur with:In my case, this is easily reproducible - even just 2 concurrent requests can trigger the error.
Suspected cause:
It appears that
create_auth_manager()inapi_fastapi/app.pycreates a new instance on every call without checking for an existing one, which may cause race conditions when multiple requests initialize the auth manager simultaneously.What you think should happen instead
Concurrent requests to
/auth/tokenshould not cause server errors.If my analysis is correct,
create_auth_manager()is not thread-safe and concurrent calls cause issues.Looking at
_AuthManagerStateandget_auth_manager(), I assume a singleton pattern is intended, but I'm not entirely sure. Either way, it seems like proper synchronization (e.g., double-checked locking) is needed.How to reproduce
/auth/token(example python script)
Note: Other endpoints like /api/v2/dags work fine under concurrent load.
Anything else
This issue started occurring after upgrading to recent versions.
(airflow:
3.0.6->3.1.6, fab:2.4.1->3.1.1)I suspect it may be related to recent refactoring (#59772, #59953), but I'm not entirely certain.
Happy to provide more details or test any fixes.
Are you willing to submit PR?
Code of Conduct