Remove dead type-mismatched guard in airflow-ctl command generation - #70945
Draft
rjgoyln wants to merge 1 commit into
Draft
Remove dead type-mismatched guard in airflow-ctl command generation#70945rjgoyln wants to merge 1 commit into
rjgoyln wants to merge 1 commit into
Conversation
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.
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.
_create_arg_for_non_primitive_typeguarded the initialisation ofdatamodels_extended_mapwith a condition that could never hold: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),
BackfillPostBodyandVariableBody(2 each) — fromaccumulating 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 (
ConnectionBodyexpands to 27entries 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?
Generated-by: Claude Code (Opus 5) following the guidelines