Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better db migrate error messages #39268

Merged
merged 1 commit into from
Apr 26, 2024

Conversation

jedcunningham
Copy link
Member

@jedcunningham jedcunningham commented Apr 25, 2024

This just cleans up our error messages for db migrate a bit to make them more consistent and intuitive.

e.g. Before:

$ airflow db migrate --show-sql-only  --from-version abc
DB: ...
Traceback (most recent call last):
  File "/home/airflow/.local/bin/airflow", line 8, in <module>
    sys.exit(main())
  File "/home/airflow/.local/lib/python3.8/site-packages/airflow/__main__.py", line 57, in main
    args.func(args)
  File "/home/airflow/.local/lib/python3.8/site-packages/airflow/cli/cli_config.py", line 49, in command
    return func(*args, **kwargs)
  File "/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/cli.py", line 114, in wrapper
    return f(*args, **kwargs)
  File "/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/providers_configuration_loader.py", line 55, in wrapped_function
    return func(*args, **kwargs)
  File "/home/airflow/.local/lib/python3.8/site-packages/airflow/cli/commands/db_command.py", line 111, in migratedb
    if parse_version(args.from_version) < parse_version("2.0.0"):
  File "/home/airflow/.local/lib/python3.8/site-packages/packaging/version.py", line 54, in parse
    return Version(version)
  File "/home/airflow/.local/lib/python3.8/site-packages/packaging/version.py", line 200, in __init__
    raise InvalidVersion(f"Invalid version: '{version}'")
packaging.version.InvalidVersion: Invalid version: 'abc'

After:

$ airflow db migrate --show-sql-only --from-version abc
DB: ...
Invalid version 'abc' supplied as `--from-version`.

and before:

$ airflow db migrate --to-version 2.1.20
DB: ...
Upgrading to version 2.1.20 is not supported.

After:

$ airflow db migrate --to-version 2.1.20
DB: ...
Unknown version '2.1.20' supplied as `--to-version`.

This just cleans up our error messages for `db migrate` a bit to make
them more consistent and intuitive.
@uranusjr uranusjr merged commit 8188da7 into apache:main Apr 26, 2024
39 checks passed
@uranusjr uranusjr deleted the better_db_upgrade_error_messages branch April 26, 2024 03:03
@utkarsharma2 utkarsharma2 added the type:bug-fix Changelog: Bug Fixes label Jun 4, 2024
@utkarsharma2 utkarsharma2 added this to the Airflow 2.9.2 milestone Jun 4, 2024
@ephraimbuddy ephraimbuddy added type:improvement Changelog: Improvements and removed type:bug-fix Changelog: Bug Fixes labels Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:CLI type:improvement Changelog: Improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants