Skip to content

Remove dead type-mismatched guard in airflow-ctl command generation - #70945

Draft
rjgoyln wants to merge 1 commit into
apache:mainfrom
rjgoyln:fix-airflowctl-datamodel-field-dedup
Draft

Remove dead type-mismatched guard in airflow-ctl command generation#70945
rjgoyln wants to merge 1 commit into
apache:mainfrom
rjgoyln:fix-airflowctl-datamodel-field-dedup

Conversation

@rjgoyln

@rjgoyln rjgoyln commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

_create_arg_for_non_primitive_type guarded the initialisation of
datamodels_extended_map with a condition that could never hold:

parameter_type_map = getattr(generated_datamodels, parameter_type)   # a Pydantic model class
if parameter_type_map not in self.datamodels_extended_map.keys():    # dict is keyed by model *name*

The map is keyed by the model name, so comparing the class object against
those keys is always True.

The dead guard turned out to be load-bearing. The field loop beneath it
appends unconditionally, so the always-taken reset was the only thing
keeping datamodels that several operations share — ConnectionBody
(3 operations), BackfillPostBody and VariableBody (2 each) — from
accumulating a duplicate copy of their fields on every visit. Repairing
the comparison to match the key type would therefore have introduced the
duplication rather than removed it (ConnectionBody expands to 27
entries instead of 9).

The guard is dropped in favour of the unconditional reset it was already
performing, so behaviour is unchanged and the intent is now honest.

Because the change is behaviour-preserving, the accompanying test passes
against both the old and the new code — it exists to fail against the
plausible-looking "fix" above, which is the trap this code invites. It
asserts the exact expected field list rather than merely the absence of
duplicates, so it also pins completeness and ordering.


Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Opus 5)

Generated-by: Claude Code (Opus 5) following the guidelines

The condition compared a Pydantic model class against a dict keyed by
model name, so it never held. It happened to be load-bearing: it forced
the field list to be rebuilt on every visit, which is what kept
datamodels shared by several operations (ConnectionBody, VariableBody,
BackfillPostBody) from accumulating duplicate entries. Correcting the
comparison to match the key type would have silently introduced those
duplicates, so the guard is dropped in favour of the unconditional reset
it was already performing.
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.

1 participant