Repository navigation
Stop rebuilding the FAB app on every users and roles API call - #73104
Merged
vincbeck merged 3 commits intoOct 1, 2026
Merged
Conversation
namanjain24-sudo
force-pushed
the
fix-fab-api-appbuilder-per-request
branch
from
September 14, 2026 08:41
9cac59e to
d99f262
Compare
Contributor
Author
|
Thanks for the careful review, both points are addressed now.
I also rebased on latest main and reran everything there. The api_fastapi tests pass on sqlite and Postgres 16, the full fab unit suite passes, prek and mypy are clean, and the |
Contributor
|
Tested locally on my side and no longer have any issue, thanks |
vincbeck
reviewed
Sep 17, 2026
The users, roles and permissions routes wrapped each request in the CLI helper get_application_builder(), which builds a new Flask app and AppBuilder every time and keeps each one alive through its cache. Use the auth manager's own Flask app instead, the same way the login routes do.
…ync change Add tests that send real requests through the auth manager's Flask app and check it is not rebuilt, and note in the changelog that the role and permission sync no longer runs on each API call.
The changelog note about the role and permission sync is not needed, per review: the provider changelog is prepared at release time and reserved for breaking changes.
namanjain24-sudo
force-pushed
the
fix-fab-api-appbuilder-per-request
branch
from
September 17, 2026 18:17
d99f262 to
5bea57f
Compare
vincbeck
approved these changes
Sep 17, 2026
This was referenced Sep 25, 2026
Contributor
Author
|
This has been approved and CI is green — would appreciate it if someone with merge access could merge this when they get a chance. Thanks! Drafted-by: Claude Code (Sonnet 5); reviewed by @namanjain24-sudo before posting |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The users, roles and permissions endpoints under
/auth/fab/v1wrapped every request inget_application_builder(), the helper written for the FAB CLI commands. It creates a new Flask app per call, so the@cacheon_return_appbuildernever hits and keeps every app alive. Each request also re-runsinit_appbuilder, which swaps the auth manager'sappbuilderfor the throwaway one and, with the defaultupdate_fab_perms, runs a fullsync_roles().These routes now use the auth manager's own Flask app through
_get_flask_app(), the same way the login routes already do. The CLI helper is unchanged.I ran a local
airflow api-server(sqlite, one worker) and sent 400 authenticated GETs to users and roles, 8 at a time:Postgres 16 showed the same pattern. The fab unit tests pass on sqlite and Postgres 16, and the API server also behaves correctly on MySQL 8.
One behaviour change:
sync_roles()no longer runs on every request, so a role created through the API without actions doesn't getcan_readonWebsiteuntil the next startup sync orairflow sync-perm. Roles created in the UI already work this way.closes: #72937
Was generative AI tooling used to co-author this PR?
Generated-by: a Gen-AI coding assistant, following the guidelines. I reviewed the change and ran the tests and the checks above locally.