Skip to content

Fix misleading error for malformed version in airflow db downgrade - #72331

Merged
potiuk merged 1 commit into
apache:mainfrom
henry3260:fix-db-downgrade-version-validation
Sep 7, 2026
Merged

Fix misleading error for malformed version in airflow db downgrade#72331
potiuk merged 1 commit into
apache:mainfrom
henry3260:fix-db-downgrade-version-validation

Conversation

@henry3260

Copy link
Copy Markdown
Contributor

Why

airflow db migrate validates --to-version / --from-version with parse_version before resolving them to an Alembic revision, but airflow db downgrade does not. A malformed value therefore falls through to the revision lookup, which fails to parse it and returns None, and the user gets:

Downgrading to version abc is not supported.

That reads as though abc is a real version that downgrade refuses to target, pointing users at the docs instead of at their typo. migrate reports Invalid version 'abc' supplied as --to-version. for the same input.

What

  • airflow-core/src/airflow/cli/commands/db_command.py: run_db_downgrade_command now validates --from-version and --to-version with parse_version before the revision lookup, raising the same Invalid version ... message as run_db_migrate_command. The existing Unknown version / not supported messages 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 for not supported now uses 2.1.25 (well-formed but unknown, matching the migrate tests) so that path stays covered.
  • Yes - Claude Code

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.
@potiuk
potiuk merged commit fb8779b into apache:main Sep 7, 2026
73 checks passed
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants