Fix FAB ignoring create_metadata_engine from local settings - #71674
Open
rjgoyln wants to merge 2 commits into
Open
Fix FAB ignoring create_metadata_engine from local settings#71674rjgoyln wants to merge 2 commits into
rjgoyln wants to merge 2 commits into
Conversation
rjgoyln
force-pushed
the
fix/fab-metadata-engine-hook
branch
from
August 16, 2026 12:14
9985ca7 to
6788fd5
Compare
Deployments that authenticate to the metadata database with short-lived credentials override create_metadata_engine in airflow_local_settings.py so a do_connect handler can mint a token per physical connection. Flask-SQLAlchemy built a second engine straight from the connection URI, so those handlers never ran and `airflow users create` — the Helm chart's create-user job — connected without a password while the migrate job and the API server succeeded. closes: apache#71664
rjgoyln
force-pushed
the
fix/fab-metadata-engine-hook
branch
from
August 16, 2026 15:36
6788fd5 to
ef5346e
Compare
rjgoyln
marked this pull request as ready for review
August 16, 2026 15:49
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.
Summary
airflow users create— the Helm chart's create-user job — fails on deployments that authenticate to the metadata database with short-lived credentials, while the migrate job and the API server of the same release succeed:Those deployments leave the password out of
sql_alchemy_connand overridecreate_metadata_engineinairflow_local_settings.pyto mint an RDS IAM token per physical connection. Onlyconfigure_orm()calls that hook, so the engine Flask-SQLAlchemy builds from the bare URI arrives with no credentials at all. The DB manager and the auth manager's Flask app carry the same gap; the API server escapes it only where deployments fall back to registering a globalEnginelistener.Taking the default bind from the engine Airflow already built brings its connect args, pool settings and event handlers along with the hook. Only a bind that resolves to the metadata database is taken over, so secondary
SQLALCHEMY_BINDSand awebserver_config.pyaimed at a database of its own keep their own engines. The override goes through_make_engine, which Flask-SQLAlchemy documents as internal and free to change signature, and the provider pins onlyflask-sqlalchemy>=3.0.5.Behavior change
FAB shares Airflow's metadata engine and pool rather than building one of its own, so the FAB REST API routes no longer create and dispose an engine per request.
SQLALCHEMY_ENGINE_OPTIONSfromwebserver_config.pyno longer applies to that bind.closes: #71664
Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Opus 5) following the guidelines