Fix misleading error for malformed version in airflow db downgrade - #72331
Merged
Conversation
The downgrade command skipped the version-format check that migrate performs, so a typo in --to-version surfaced as "Downgrading to version X is not supported". That reads as if the version exists and downgrading to it is unsupported, sending users to the docs instead of to their typo. --from-version had the same gap.
henry3260
requested review from
bugraoz93,
dheerajturaga and
potiuk
as code owners
August 31, 2026 13:20
potiuk
approved these changes
Sep 7, 2026
pierrejeambrun
pushed a commit
to astronomer/airflow
that referenced
this pull request
Sep 8, 2026
…pache#72331) The downgrade command skipped the version-format check that migrate performs, so a typo in --to-version surfaced as "Downgrading to version X is not supported". That reads as if the version exists and downgrading to it is unsupported, sending users to the docs instead of to their typo. --from-version had the same gap.
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.
Why
airflow db migratevalidates--to-version/--from-versionwithparse_versionbefore resolving them to an Alembic revision, butairflow db downgradedoes not. A malformed value therefore falls through to the revision lookup, which fails to parse it and returnsNone, and the user gets:That reads as though
abcis a real version that downgrade refuses to target, pointing users at the docs instead of at their typo.migratereportsInvalid version 'abc' supplied as --to-version.for the same input.What
airflow-core/src/airflow/cli/commands/db_command.py:run_db_downgrade_commandnow validates--from-versionand--to-versionwithparse_versionbefore the revision lookup, raising the sameInvalid version ...message asrun_db_migrate_command. The existingUnknown version/not supportedmessages are unchanged and now only fire for well-formed versions with no matching revision.airflow-core/tests/unit/cli/commands/test_db_command.py: added malformed-version cases for both flags at the function and CLI level; the existing CLI case fornot supportednow uses2.1.25(well-formed but unknown, matching themigratetests) so that path stays covered.