Skip to content

Fix bulk create+overwrite silently resetting unset fields on pools and connections#68645

Merged
vincbeck merged 3 commits into
apache:mainfrom
aws-mwaa:bugfix/bulk-overwrite-preserves-team-name
Jun 17, 2026
Merged

Fix bulk create+overwrite silently resetting unset fields on pools and connections#68645
vincbeck merged 3 commits into
apache:mainfrom
aws-mwaa:bugfix/bulk-overwrite-preserves-team-name

Conversation

@seanghaeli

@seanghaeli seanghaeli commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Problem

The bulk APIs (PATCH /api/v2/pools and PATCH /api/v2/connections) handle a create action with action_on_existence=overwrite by dumping the whole request body and setattr-ing every field onto the existing record. Because the dump includes fields the request omitted (at their model defaults), an overwrite that changes only e.g. slots silently resets every unmentioned field.

Fix

Overwrite only the fields the request actually provided, via model_dump(exclude_unset=True). Omitted fields keep their current value; an explicitly-set field (even None) is still applied. Applied to both the pools and connections bulk-create overwrite paths (variables use Variable.set and are unaffected).

Tests

  • test_bulk_create_overwrite_preserves_unset_team_name (pools + connections): a team-owned record overwritten with a body that omits team_name keeps its team_name. Fails on the old code (team_name becomes None), passes with the fix.
  • test_bulk_create_overwrite_applies_explicit_team_name (pools): an explicitly-provided team_name is still applied, so the fix doesn't over-correct.

…d connections

A bulk 'create' with action_on_existence=overwrite dumped the whole request body
and set every field on the existing record, so fields the request omitted were
reset to their defaults. For multi-team setups this silently nulled an existing
pool's or connection's team_name ownership when an overwrite changed only e.g.
slots; description and include_deferred were affected too.

Only write the fields the request actually provided (model_dump(exclude_unset=True)),
so omitted fields keep their current value while explicitly-set fields (even None)
are still applied. Adds regression tests for both pools and connections.

@o-nikolas o-nikolas 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.

lgtm, I'll wait to merge until @vincbeck has had a look

@o-nikolas o-nikolas added this to the Airflow 3.3.0 milestone Jun 17, 2026
@potiuk potiuk added the ready for maintainer review Set after triaging when all criteria pass. label Jun 17, 2026

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

Nice catch

@vincbeck
vincbeck merged commit bd9270d into apache:main Jun 17, 2026
77 checks passed
@vincbeck
vincbeck deleted the bugfix/bulk-overwrite-preserves-team-name branch June 17, 2026 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:API Airflow's REST/HTTP API ready for maintainer review Set after triaging when all criteria pass.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants