Skip to content

Stop airflowctl updates from resetting omitted bool fields - #74383

Merged
potiuk merged 2 commits into
apache:mainfrom
Shawnsuun:shawn/airflowctl-dags-update-bool
Nov 1, 2026
Merged

potiuk merged 2 commits into
apache:mainfrom
Shawnsuun:shawn/airflowctl-dags-update-bool

Conversation

@Shawnsuun

@Shawnsuun Shawnsuun commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Generated boolean flags in airflowctl default to False unless the datamodel is on an allowlist. For optional fields that means an omitted flag overwrites the stored value:

  • airflowctl dags update <dag_id> without --is-paused / --no-is-paused sends {"is_paused": false, "scheduling_state": null} and silently unpauses a paused Dag. It also makes --scheduling-state <state> unusable, because is_paused: false is always sent with it and the server requires exactly one of the two.
  • airflowctl pools update --pool p --slots 10 sends include_deferred: false and turns it off on a pool that had it on.
  • Other optional bool fields (for example backfill create --run-on-latest-version) are forced to False instead of being left to the server.

This PR:

  • Uses each field's own default for every generated bool flag and drops the field_bool_default_datamodels allowlist. Fields that default to True/False keep that default (tasks clear still dry-runs by default); optional fields stay None and are left out of the request.
  • Leaves None fields out of the dags update request body (the other update/create operations already did this). This also stops sending "scheduling_state": null, which older servers such as 3.3.2 reject as an extra field.
  • Makes dags update fail on the client with "Provide exactly one of --is-paused / --no-is-paused or --scheduling-state." when it gets neither or both, instead of sending the request and showing the server's validation error.

User-visible changes:

  • A bare airflowctl dags update <dag_id> used to unpause the Dag and now exits with the message above.
  • pools update without --include-deferred / --no-include-deferred no longer sends the field, so the server rejects the request (it requires the field on a PATCH without update_mask) instead of turning the setting off.
  • backfill create without --run-on-latest-version / --no-run-on-latest-version no longer sends run_on_latest_version=false. The server now resolves it (the Dag's rerun_with_latest_version, then [core] rerun_with_latest_version, then True for backfills), so a backfill that used to run on the original bundle version now runs on the latest one by default. --no-run-on-latest-version keeps the old behavior.

related: #73768
related: #73931 (a server-side change that would let pools update send only the fields it changes)

Reproduction (before)

Against a local api-server built from main (SQLite, simple auth manager), with one Dag that starts paused. >>> shows the PATCH body airflowctl sent.

airflowctl at main (3e302fd257)
$ airflowctl dags pause repro_dag
    -> Dag state: is_paused=True scheduling_state=paused
$ airflowctl dags update repro_dag
>>> PATCH /api/v2/dags/repro_dag? body={"is_paused":false,"scheduling_state":null}
<<< 200 
    -> Dag state: is_paused=False scheduling_state=active
$ airflowctl dags update repro_dag --scheduling-state paused
>>> PATCH /api/v2/dags/repro_dag? body={"is_paused":false,"scheduling_state":"paused"}
<<< 422 Value error, Exactly one of `is_paused` or `scheduling_state` must be provided
    -> Dag state: is_paused=True scheduling_state=paused

The behaviour after this PR is covered by the unit tests below; I did not re-run the server reproduction for the latest revision.

Tests

  • uv run --project airflow-ctl pytest airflow-ctl/tests -q: 717 passed (after merging main). The new cases for a bare/conflicting dags update, an omitted pools update --include-deferred, an omitted backfill create --run-on-latest-version, and the dags update request body fail without the change; the explicit-flag cases pin that --is-paused / --no-is-paused, --include-deferred / --no-include-deferred and --run-on-latest-version / --no-run-on-latest-version still send True / False.
  • prek mypy-airflow-ctl hook (run on commit): passed.
  • The pools update command in the airflow-ctl-tests integration list now passes --no-include-deferred explicitly, because the server requires the field on a PATCH without update_mask. I did not run the integration tests locally (they need a Docker Compose stack).
  • airflowctl <command> --help output for dags update, dags trigger, pools create, pools update, backfill create and tasks clear is identical with and without the change, so the help images are unaffected. generate-airflowctl-help-images was skipped locally because it needs breeze.

No newsfragment, because airflow-ctl doesn't use them. airflow-ctl/RELEASE_NOTES.rst is not edited here because its header says it is populated at release time and must not be edited in PRs.


Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

Generated-by: GitHub Copilot CLI (Claude Opus 5.5) following the guidelines


  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.

Copilot AI 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.

🟢 Approval recommended

The focused change fixes both reported behaviors and includes regression tests that fail without it.

0 open findings

What changed in this PR

Prevents airflowctl dags update from unintentionally unpausing Dags when pause state is omitted.

Changes:

  • Preserves DAGPatchBody.is_paused’s None default.
  • Adds regression coverage for omitted pause flags and scheduling-state updates.
File Description
airflow-ctl/​src/​airflowctl/​ctl/​cli_config.py Applies datamodel boolean defaults to DAGPatchBody.
airflow-ctl/​tests/​airflow_ctl/​ctl/​test_cli_config.py Verifies omitted pause flags remain unset.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@potiuk potiuk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, a bare dags update must not unpause a Dag. Details inline; the main point is that the same bug exists in other commands, so the fix should go one level deeper.

Since a bare airflowctl dags update my_dag used to unpause and now gets a 422 from the server, please also:

  • add a line to airflow-ctl/RELEASE_NOTES.rst (airflow-ctl doesn't use newsfragments),
  • ideally fail on the client with "one of --is-paused / --no-is-paused / --scheduling-state is required" instead of sending a body with both fields null and showing the raw server validation error,
  • add a test that --no-is-paused / --is-paused still reach the body as False / True now that the default is None.

Drafted-by: Claude Code (Opus 5.5); reviewed by @potiuk before posting

@Shawnsuun Shawnsuun changed the title Stop airflowctl dags update from unpausing Dags by default Stop airflowctl updates from resetting omitted bool fields Oct 19, 2026
@Shawnsuun

Shawnsuun commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks for the review. Addressed in 2c83ba4340:

  • Generated bool flags now follow each field's default for every datamodel (see the inline thread), so this also fixes pools update and the other optional bool fields.
  • dags update fails on the client with "Provide exactly one of --is-paused / --no-is-paused or --scheduling-state." when it gets neither or both, and it leaves None fields out of the request body.
  • Tests that --is-paused / --no-is-paused reach the body as True / False were added in 4c2e3447b3, and there are matching cases for --include-deferred / --no-include-deferred.
  • airflow-ctl/RELEASE_NOTES.rst: I didn't edit it, because its header says it is populated at release time and must not be edited in PRs. I described the user-visible change in the PR description instead. Happy to add a line here if you still want one.

@Andrushika Andrushika 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, the change looks right to me. I checked that only four flags change their default, all from False to None, and that the help text stays the same. Two small notes on the description and one test nit inline.


Drafted-by: Claude Code (Opus 5.5); reviewed by @Andrushika before posting

Shawnsuun and others added 2 commits November 1, 2026 09:55
Squashed onto main for a clean rebase. Includes the integration-test and backfill test changes from Shahar Epstein's commit 82a7ed8e0c.

Generated-by: GitHub Copilot CLI (Claude Opus 5.5)
The server requires include_deferred on a pool PATCH without an update mask, so an omitted flag now gets the same client-side message as dags update instead of a raw 422.

Generated-by: Claude Opus 5
@potiuk
potiuk force-pushed the shawn/airflowctl-dags-update-bool branch from 2ed1141 to e99415f Compare November 1, 2026 09:01

@potiuk potiuk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @Shawnsuun — this fixes the omitted-bool-flag overwrite cleanly, and the tests cover each path. I applied two small maintainer changes on your branch so it can go in:

  • Rebased onto current main as a single commit (2c8d896722), since the branch's merge commits no longer replayed cleanly. Your authorship is kept, and the message credits the test changes from 82a7ed8e0c.
  • pools update now fails on the client when --include-deferred / --no-include-deferred is omitted (e99415fc6a, airflow-ctl/src/airflowctl/ctl/cli_config.py), with the same kind of message dags update gives, instead of surfacing the server's raw 422. test_pools_update_requires_include_deferred covers it.

My earlier change request is addressed.


This review was drafted by an AI-assisted tool and
confirmed by an Apache Airflow maintainer. The maintainer
approving this PR has read the findings and signed off. If
something feels off, please reply on the PR and a maintainer
will follow up.

More on how Apache Airflow handles maintainer review:
Contributing guide.

@potiuk
potiuk enabled auto-merge (squash) November 1, 2026 09:13
@potiuk
potiuk merged commit 9cde6aa into apache:main Nov 1, 2026
91 checks passed
@shahar1 shahar1 mentioned this pull request Nov 7, 2026
1 task done
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.

6 participants