Skip to content

Fix airflowctl operations create command validation error - #69317

Merged
shahar1 merged 4 commits into
apache:mainfrom
Prab-27:fix-airflowctl-connection-create-command
Oct 30, 2026
Merged

shahar1 merged 4 commits into
apache:mainfrom
Prab-27:fix-airflowctl-connection-create-command

Conversation

@Prab-27

@Prab-27 Prab-27 commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

airflowctl operations create command failed validation error on pydantic side not arg side this throws error and check response in arg parseand

All required postional params pass through command but these are required params and part of that body response .

i havecheked pools , connections create command shows error since the input body required whole entity as response and
pydanic failed on validation errror this PR aims to catch errors before processing
airflowctl connections create shows Traceback (most recent call last):

$ airflowctl pools create
Please enter password for encrypted keyring: 
Traceback (most recent call last):
 File "/usr/python/bin/airflowctl", line 10, in <module>
   sys.exit(main())
            ^^^^^^
 File "/opt/airflow/airflow-ctl/src/airflowctl/__main__.py", line 34, in main
   safe_call_command(args.func, args=args)
 File "/opt/airflow/airflow-ctl/src/airflowctl/ctl/cli_config.py", line 78, in safe_call_command
   function(args)
 File "/opt/airflow/airflow-ctl/src/airflowctl/api/client.py", line 575, in wrapper
   return func(*args, api_client=api_client, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 File "/opt/airflow/airflow-ctl/src/airflowctl/ctl/cli_config.py", line 938, in _get_func
   method_params[datamodel_param_name] = datamodel.model_validate(
                                         ^^^^^^^^^^^^^^^^^^^^^^^^^
 File "/usr/python/lib/python3.12/site-packages/pydantic/main.py", line 790, in model_validate
   return cls.__pydantic_validator__.validate_python(
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 2 validation errors for PoolBody
name
 Input should be a valid string [type=string_type, input_value=None, input_type=NoneType]
   For further information visit https://errors.pydantic.dev/2.14/v/string_type
slots
 Input should be a valid integer [type=int_type, input_value=None, input_type=NoneType]
   For further information visit https://errors.pydantic.dev/2.14/v/int_type

 airflowctl connections create
Please enter password for encrypted keyring: 
Traceback (most recent call last):
  File "/usr/python/bin/airflowctl", line 10, in <module>
    sys.exit(main())
             ^^^^^^
  File "/opt/airflow/airflow-ctl/src/airflowctl/__main__.py", line 34, in main
    safe_call_command(args.func, args=args)
  File "/opt/airflow/airflow-ctl/src/airflowctl/ctl/cli_config.py", line 78, in safe_call_command
    function(args)
  File "/opt/airflow/airflow-ctl/src/airflowctl/api/client.py", line 575, in wrapper
    return func(*args, api_client=api_client, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/airflow/airflow-ctl/src/airflowctl/ctl/cli_config.py", line 938, in _get_func
    method_params[datamodel_param_name] = datamodel.model_validate(
                                          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/python/lib/python3.12/site-packages/pydantic/main.py", line 790, in model_validate
    return cls.__pydantic_validator__.validate_python(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 2 validation errors for ConnectionBody
connection_id
  Input should be a valid string [type=string_type, input_value=None, input_type=NoneType]
    For further information visit https://errors.pydantic.dev/2.14/v/string_type
conn_type
  Input should be a valid string [type=string_type, input_value=None, input_type=NoneType]
    For further information visit https://errors.pydantic.dev/2.14/v/string_type 

Add is_required() flag to arg to catch required params also add tests for all operations method
Add a static method to check params with none value but not defaults

After fix :

airflowctl pools create --name=helloo --slots=4
Please enter password for encrypted keyring: 
[{"name": "helloo", "slots": "4", "description": null, "include_deferred": "False", "occupied_slots": "0", "running_slots": "0", "queued_slots": "0", "scheduled_slots": "0", "open_slots": "4", "deferred_slots": "0", "team_name": null}]

airflowctl connections create

sage: airflowctl connections create [-h] [--api-token API_TOKEN] --conn-type
                                     CONN_TYPE --connection-id CONNECTION_ID
                                     [--description DESCRIPTION] [-e ENV]
                                     [--extra EXTRA] [--host HOST]
                                     [--login LOGIN] [--password PASSWORD]
                                     [--port PORT] [--team-name TEAM_NAME]
                                     [--output (table, json, yaml, plain)]

Create a new connection

Options:
  -h, --help            show this help message and exit
  --api-token API_TOKEN
                        The token to use for authentication
  --conn-type CONN_TYPE
                        conn_type for connection operation
  --connection-id CONNECTION_ID
                        connection_id for connection operation
  --description DESCRIPTION
                        description for connection operation
  -e, --env ENV         The environment to run the command in
  --extra EXTRA         extra for connection operation
  --host HOST           host for connection operation
  --login LOGIN         login for connection operation
  --password PASSWORD   password for connection operation
  --port PORT           port for connection operation
  --team-name TEAM_NAME
                        team_name for connection operation
  --output, -o (table, json, yaml, plain)
                        Output format. Allowed values: json, yaml, plain, table (default: json)

airflowctl connections create command error: the following arguments are required: --conn-type, --connection-id, see help above.

… tests


Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below) some tests are written here with - AI generated

  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.

Important

🛠️ Maintainer triage note for @Prab-27 · by @potiuk · 2026-07-08 15:38 UTC

Helpful heads-up from the maintainers — please address before this PR can be reviewed:

  • Image build failing (Additional PROD image tests / Airflow CTL integration tests with PROD image). See the contributor guide.

Full criteria: Pull Request quality criteria.

The ball is in your court — you've been assigned to this PR. Fix the above, then mark it Ready for review.

Automated triage — may be imperfect; a maintainer takes the next look.

@SameerMesiah97 SameerMesiah97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think there are a few thing wrong with this PR (even though it looks a simple fix):

  1. Is this actually a bug? From the traceback it looks like airflowctl connections create is being invoked without the required connection information. The poor UX is the ValidationError, but I'm not convinced changing the API is the right fix for invalid input

  2. The traceback suggest execption is raised while constructing the ConnectionBody in cli_config.py, before client.connections.create() is ever called. Shouldn't the fix (if needed) live there instead?

  3. Doesn't this introduce a breaking change? Existing callers of client.connections.create() will now need to provide connection_id and conn_type explicitly.

  4. Why do connection_id and conn_type need to be separate parameters at all? They're already required fields on ConnectionBody, so this duplicates the source of truth and allows the values to diverge.

I think 1 should be addressed first. Could you provide a resproduction that illustrates that this is a genuine bug rather than due to invalid user input? I believe what might be needed here is clearer error logging that surfaces the root cause i.e. missing arguments rather a type validation error.

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions.

@github-actions github-actions Bot added the stale Stale PRs per the .github/workflows/stale.yml policy file label Aug 29, 2026
@github-actions github-actions Bot closed this Sep 3, 2026
@shahar1 shahar1 reopened this Oct 27, 2026
@shahar1 shahar1 removed the stale Stale PRs per the .github/workflows/stale.yml policy file label Oct 27, 2026
@Prab-27
Prab-27 force-pushed the fix-airflowctl-connection-create-command branch 2 times, most recently from c6e11eb to ddeadcf Compare October 29, 2026 22:06
@Prab-27
Prab-27 marked this pull request as draft October 29, 2026 22:08
@Prab-27
Prab-27 marked this pull request as ready for review October 29, 2026 22:15
@Prab-27 Prab-27 changed the title Fix airflowctl connection create command validation error Fix airflowctl operations create command validation error Oct 30, 2026
@Prab-27
Prab-27 force-pushed the fix-airflowctl-connection-create-command branch from ddeadcf to 0ea6a12 Compare October 30, 2026 16:47
@shahar1
shahar1 merged commit 1c3b3de into apache:main Oct 30, 2026
91 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

Backport failed to create: airflow-ctl/v0-1-test. View the failure log Run details

Note: As of Merging PRs targeted for Airflow 3.X
the committer who merges the PR is responsible for backporting the PRs that are bug fixes (generally speaking) to the maintenance branches.

In matter of doubt please ask in #release-management Slack channel.

Status Branch Result
❌ airflow-ctl/v0-1-test Commit Link

You can attempt to backport this manually by running:

cherry_picker 1c3b3de airflow-ctl/v0-1-test

This should apply the commit to the airflow-ctl/v0-1-test branch and leave the commit in conflict state marking
the files that need manual conflict resolution.

After you have resolved the conflicts, you can continue the backport process by running:

cherry_picker --continue

If you don't have cherry-picker installed, see the installation guide.

shahar1 added a commit that referenced this pull request Oct 31, 2026
#69317 made required request-body fields required in argparse, and
#75177 added a test expecting the post-parse validation to report a
missing --conn-type. Each passed on its own, but together argparse
rejects the command during parsing, so the test failed on main. The
argparse error is the intended behaviour; the test now checks it.
shahar1 added a commit to shahar1/airflow that referenced this pull request Oct 31, 2026
…dation error (apache#69317)

The only conflict was context: _find_subgroup_suffix from the operation subgroups change is not on this branch and stays out. The fix itself applies unchanged.

(cherry picked from commit 1c3b3de)

Co-authored-by: Pratiksha Badheka <[email protected]>
shahar1 added a commit to shahar1/airflow that referenced this pull request Oct 31, 2026
…he#76092)

apache#69317 made required request-body fields required in argparse, and
apache#75177 added a test expecting the post-parse validation to report a
missing --conn-type. Each passed on its own, but together argparse
rejects the command during parsing, so the test failed on main. The
argparse error is the intended behaviour; the test now checks it.

(cherry picked from commit 9c164b5)
shahar1 added a commit that referenced this pull request Oct 31, 2026
…dation error (#69317) (#76116)

* [airflow-ctl/v0-1-test] Fix airflowctl operations create command validation error (#69317)

The only conflict was context: _find_subgroup_suffix from the operation subgroups change is not on this branch and stays out. The fix itself applies unchanged.

(cherry picked from commit 1c3b3de)

Co-authored-by: Pratiksha Badheka <[email protected]>

* Fix airflowctl required-option test broken by concurrent merges (#76092)

#69317 made required request-body fields required in argparse, and
#75177 added a test expecting the post-parse validation to report a
missing --conn-type. Each passed on its own, but together argparse
rejects the command during parsing, so the test failed on main. The
argparse error is the intended behaviour; the test now checks it.

(cherry picked from commit 9c164b5)

---------

Co-authored-by: Pratiksha Badheka <[email protected]>
shahar1 added a commit that referenced this pull request Nov 19, 2026
…dation error (#69317) (#76116)

* [airflow-ctl/v0-1-test] Fix airflowctl operations create command validation error (#69317)

The only conflict was context: _find_subgroup_suffix from the operation subgroups change is not on this branch and stays out. The fix itself applies unchanged.

(cherry picked from commit 1c3b3de)

Co-authored-by: Pratiksha Badheka <[email protected]>

* Fix airflowctl required-option test broken by concurrent merges (#76092)

#69317 made required request-body fields required in argparse, and
#75177 added a test expecting the post-parse validation to report a
missing --conn-type. Each passed on its own, but together argparse
rejects the command during parsing, so the test failed on main. The
argparse error is the intended behaviour; the test now checks it.

(cherry picked from commit 9c164b5)

---------

Co-authored-by: Pratiksha Badheka <[email protected]>
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.

3 participants