Stop airflowctl update commands from clearing fields left unset - #71333
Open
DHBhensdadia wants to merge 1 commit into
Open
Stop airflowctl update commands from clearing fields left unset#71333DHBhensdadia wants to merge 1 commit into
DHBhensdadia wants to merge 1 commit into
Conversation
The API treats every key present in a PATCH body as an intentional value, so an update that omitted a flag arrived with those fields set to null and silently cleared them. Changing only a connection's host wiped its login, port, schema and description; pool and variable descriptions were lost the same way. argparse fills an omitted flag with None and the generated command builds the whole datamodel from those values, so by serialization time the client can no longer tell "not supplied" from "set to null". The create methods already guard against this; the update methods did not. The same omission was reported for dags trigger in apache#70327, where it surfaces as a request older API servers reject rather than as lost data.
DHBhensdadia
requested review from
bugraoz93,
dheerajturaga,
henry3260 and
potiuk
as code owners
August 8, 2026 15:01
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
airflowctl connections update --connection-id pg_prod --conn-type postgres --host db2.example.comerases that connection's login, port, schema and description.
The API applies every key present in a PATCH body, so a field the user never typed arrives as
nulland is stored as one. argparse fills an omitted flag with
None, and the generated command buildsthe whole datamodel from those values, so by the time the body is serialized the client can no longer
distinguish "not supplied" from "set to null".
The
createmethods inoperations.pyalready passexclude_none=True; theupdatemethods didnot. This is the same omission reported in #70327 for
dags trigger, where it shows up as a requestolder API servers reject rather than as lost data.
Reproduction
Against a real Airflow 3.4.0 API server on SQLite (no Docker):
With this change, each of those commands sends only the fields the user passed, and the untouched
fields keep their stored values.
Scope
PoolsOperations.updatestill sendsinclude_deferred: false, becauseFalseis notNone. Thathas a different cause —
_get_bool_arg_defaultinctl/cli_config.pyreturnsFalsefor everydatamodel outside its one-entry allowlist instead of the field's declared default — and is left for a
separate PR.
Also deliberately unchanged:
DagsOperations.update—DAGPatchBodyhas a single requiredboolfield, soexclude_nonewouldbe a no-op with nothing to test.
bulkmethods — they PATCH a collection endpoint with a body of actions, where anullinsidean action may be meaningful. Different semantics.
ConnectionsOperations.test— POST, not PATCH; it does not mutate stored state.default_poolremains un-updatable throughairflowctl(Only slots and included_deferred can be modified on Default Pool). The server only permits it whenupdate_maskis sent, and the clientnever sends one. Separate fix.
test_update_uses_schema_alias_in_request_bodyasserted the old body including itsnullkeys; itsexpectation is updated. Its subject — that the
schemaalias is used rather thanschema_— isunchanged and still asserted.
related: #70327
Was generative AI tooling used to co-author this PR?
Claude Code (Opus 5) following the guidelines