Skip to content

Fix airflowctl connections test failing on stored connections - #73098

Merged
henry3260 merged 1 commit into
apache:mainfrom
Eason09053360:fix-airflowctl-connections-test-null-fields
Sep 13, 2026
Merged

Fix airflowctl connections test failing on stored connections#73098
henry3260 merged 1 commit into
apache:mainfrom
Eason09053360:fix-airflowctl-connections-test-null-fields

Conversation

@Eason09053360

Copy link
Copy Markdown
Contributor

Why

airflowctl connections test --connection-id <id> --conn-type <type> is rejected for any
connection that has a stored host or port:

Client error message: {'detail': 'The host or port to test differs from the stored connection.
Include the credentials to test in the request body.'}

The endpoint fills the fields the caller leaves out from the stored connection, and works out
which fields the caller meant to override from the keys present in the body — model_fields_set
(routes/public/connections.py:387, services/public/connections.py:47). A key whose value is
null still counts as present.

The generated CLI builds ConnectionBody from a dict holding every field
(cli_config.py:858), so argparse's None for each flag the user did not pass goes out as an
explicit null. The server reads that as "clear these fields": the stored host reads as changed,
no credentials were supplied, and the request is refused. On a connection with no host it is not
refused, but the stored login, password and extra are overwritten with None and a blank
connection is tested instead.

ConnectionsOperations.create already passes exclude_none=True for this reason, as do pools,
backfills and asset events; test was missed. exclude_unset=True would be a no-op, since the
command factory always populates every field. Nothing in the CLI can express an intentional
null, so dropping them loses no caller intent.

What

ConnectionsOperations.test now passes exclude_none=True.

test_test_uses_schema_alias_in_request_body asserted the full body including the seven nulls,
pinning the broken behaviour; it now expects the three keys actually set, matching
test_create_uses_schema_alias_in_request_body. Reverting the one-line fix fails it. The added
comment records why the exact body matters beyond the alias, so the assertion is not loosened
back into the bug.

Left alone to keep this to one behaviour change: update has the same root cause and is already
covered by #71333. bulk has it too, but exclude_none=True would only half-fix it — the
connections/variables/pools import commands also pass hard-coded fallbacks such as
description=v.get("description", ""), which are not None and would still overwrite stored
values under --action-on-existing-key overwrite. Fixing that means having those three commands
send only the keys present in the file.


Was generative AI tooling used to co-author this PR?
  • No

The API server fills the fields a test request leaves out from the stored
connection, and decides which fields the caller meant to override from the
keys present in the request body. Sending every unset field as an explicit
null therefore reads as "clear these", so a stored host or port counts as
changed and the request is refused; where it is not refused the stored
credentials are overwritten with nulls and a blank connection gets tested.

Nothing in the CLI can express an intentional null, so omitting them loses
no caller intent.

@justinpakzad justinpakzad 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.

Thanks for the fix, looks good to me.

@henry3260
henry3260 merged commit 65eb086 into apache:main Sep 13, 2026
97 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 65eb086 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.

henry3260 added a commit that referenced this pull request Sep 13, 2026
…ored connections (#73098) (#73102)

(cherry picked from commit 65eb086)

Co-authored-by: Y-C <easoneason0905@gmail.com>
xvega pushed a commit to xvega/airflow that referenced this pull request Sep 13, 2026
…#73098)

The API server fills the fields a test request leaves out from the stored
connection, and decides which fields the caller meant to override from the
keys present in the request body. Sending every unset field as an explicit
null therefore reads as "clear these", so a stored host or port counts as
changed and the request is refused; where it is not refused the stored
credentials are overwritten with nulls and a blank connection gets tested.

Nothing in the CLI can express an intentional null, so omitting them loses
no caller intent.

Co-authored-by: Eason09053360 <185830721+Eason09053360@users.noreply.github.com>
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