Skip to content

Fix primitive parameter type handling in dynamic CLI generation #52768

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

Merged
merged 1 commit into from
Jul 4, 2025

Conversation

mohiuddin-khan-shiam
Copy link
Contributor

Description

Problem

Primitive parameters discovered via OpenAPI introspection were always registered
with argparse as str because the code used type(parameter_type) where
parameter_type itself was already a string. This caused:

  • all numeric / boolean CLI options to be parsed as strings,
  • boolean flags not to use BooleanOptionalAction,
  • mismatched data types sent to the Airflow REST API.

Solution

  • Added helper _python_type_from_string() that maps the textual type names
    ("int", "float", "bool", …) to their real Python counterparts.
  • Reworked argument creation to use that mapping and properly configure
    booleans with BooleanOptionalAction.
  • Imported datetime to support datetime.datetime mapping.

Impact

CLI arguments now receive the correct Python types at parse-time, preventing
type-related runtime errors and ensuring the generated payloads match the
API schema.

Copy link

boring-cyborg bot commented Jul 3, 2025

Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide (https://github.com/apache/airflow/blob/main/contributing-docs/README.rst)
Here are some useful points:

  • Pay attention to the quality of your code (ruff, mypy and type annotations). Our pre-commits will help you with that.
  • In case of a new feature add useful documentation (in docstrings or in docs/ directory). Adding a new operator? Check this short guide Consider adding an example DAG that shows how users should use it.
  • Consider using Breeze environment for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
  • Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
  • Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
    Apache Airflow is a community-driven project and together we are making it better 🚀.
    In case of doubts contact the developers at:
    Mailing List: [email protected]
    Slack: https://s.apache.org/airflow-slack

Copy link
Contributor

@bugraoz93 bugraoz93 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many thanks for your first PR @mohiuddin-khan-shiam! Amazing work! The Boolean part was in my TODO as a bug. I have tested and it works. It is amazing to see you fixed the bug and you also enhanced/streamlined the mapping parsing.
It looks great! Could you please rebase your branch? We can merge afterwards

@mohiuddin-khan-shiam
Copy link
Contributor Author

Done.

@bugraoz93
Copy link
Contributor

bugraoz93 commented Jul 3, 2025

Thanks for the rebase, but I think you merged the changes rather than rebase! Could you please also run static checks (pre-commit hooks) in your localand push? it is failing on the CI for ruff format and if we merge, it will break main. :) Sorry for double work!

@mohiuddin-khan-shiam
Copy link
Contributor Author

Thanks for the review! I've:

  1. Rebased my branch on the latest main
  2. Run pre-commit hooks including Ruff formatting
  3. Force-pushed the changes

The PR should now be clean and ready for another look. Let me know if you need anything else!

@bugraoz93 bugraoz93 merged commit e3706e5 into apache:main Jul 4, 2025
3 checks passed
Copy link

boring-cyborg bot commented Jul 4, 2025

Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions.

@bugraoz93
Copy link
Contributor

Congrats @mohiuddin-khan-shiam! Thanks for your work!

@mohiuddin-khan-shiam
Copy link
Contributor Author

Welcome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants