Skip to content

Fix astro run command for Airflow 3 by using db migrate#2096

Draft
vinnyjth wants to merge 1 commit into
astronomer:mainfrom
vinnyjth:fix/issue-2095-airflow3-db-migrate
Draft

Fix astro run command for Airflow 3 by using db migrate#2096
vinnyjth wants to merge 1 commit into
astronomer:mainfrom
vinnyjth:fix/issue-2095-airflow3-db-migrate

Conversation

@vinnyjth
Copy link
Copy Markdown

Fixes #2095

The astro run <dag-id> command fails on Airflow 3 runtime images because it was hardcoded to use airflow db init, which was removed in Airflow 3.0.

This commit adds version detection logic to the RunDAG function to conditionally use the appropriate database command:

  • airflow db migrate for Airflow 3+
  • airflow db init for Airflow 2

The fix follows the same pattern used in PR #1811 for the astro dev start command path.

Changes:

  • Added call to checkAirflowVersion() in the RunDAG function
  • Conditionally set dbCommand based on detected Airflow version
  • Updated error messages to use the dynamic dbCommand variable
  • Added test mocks for ListLabels() to support version detection
  • Added new test case for Airflow 3 to verify the fix

Description

Describe the purpose of this pull request.

🎟 Issue(s)

Related #XXX

🧪 Functional Testing

List the functional testing steps to confirm this feature or fix.

📸 Screenshots

Add screenshots to illustrate the validity of these changes.

📋 Checklist

  • Rebased from the main (or release if patching) branch (before testing)
  • Ran make test before taking out of draft
  • Ran make lint before taking out of draft
  • Added/updated applicable tests
  • Tested against Astro-API (if necessary).
  • Tested against Houston-API and Astronomer (if necessary).
  • Communicated to/tagged owners of respective clients potentially impacted by these changes.
  • Updated any related documentation

Fixes astronomer#2095

The `astro run <dag-id>` command fails on Airflow 3 runtime images
because it was hardcoded to use `airflow db init`, which was removed
in Airflow 3.0.

This commit adds version detection logic to the `RunDAG` function to
conditionally use the appropriate database command:
- `airflow db migrate` for Airflow 3+
- `airflow db init` for Airflow 2

The fix follows the same pattern used in PR astronomer#1811 for the
`astro dev start` command path.

Changes:
- Added call to `checkAirflowVersion()` in the `RunDAG` function
- Conditionally set `dbCommand` based on detected Airflow version
- Updated error messages to use the dynamic `dbCommand` variable
- Added test mocks for `ListLabels()` to support version detection
- Added new test case for Airflow 3 to verify the fix

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: astro run <dag-id> fails on Airflow 3 — airflow db init was removed in AF3

1 participant