Repository navigation
Stop airflowctl updates from resetting omitted bool fields - #74383
Conversation
813e142 to
40d25f6
Compare
There was a problem hiding this comment.
🟢 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’sNonedefault. - 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
left a comment
There was a problem hiding this comment.
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-stateis 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-pausedstill reach the body asFalse/Truenow that the default isNone.
Drafted-by: Claude Code (Opus 5.5); reviewed by @potiuk before posting
|
Thanks for the review. Addressed in 2c83ba4340:
|
Andrushika
left a comment
There was a problem hiding this comment.
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
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
2ed1141 to
e99415f
Compare
potiuk
left a comment
There was a problem hiding this comment.
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
mainas 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 from82a7ed8e0c. pools updatenow fails on the client when--include-deferred/--no-include-deferredis omitted (e99415fc6a,airflow-ctl/src/airflowctl/ctl/cli_config.py), with the same kind of messagedags updategives, instead of surfacing the server's raw 422.test_pools_update_requires_include_deferredcovers 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.
Generated boolean flags in airflowctl default to
Falseunless 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-pausedsends{"is_paused": false, "scheduling_state": null}and silently unpauses a paused Dag. It also makes--scheduling-state <state>unusable, becauseis_paused: falseis always sent with it and the server requires exactly one of the two.airflowctl pools update --pool p --slots 10sendsinclude_deferred: falseand turns it off on a pool that had it on.backfill create --run-on-latest-version) are forced toFalseinstead of being left to the server.This PR:
field_bool_default_datamodelsallowlist. Fields that default toTrue/Falsekeep that default (tasks clearstill dry-runs by default); optional fields stayNoneand are left out of the request.Nonefields out of thedags updaterequest 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.dags updatefail 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:
airflowctl dags update <dag_id>used to unpause the Dag and now exits with the message above.pools updatewithout--include-deferred/--no-include-deferredno longer sends the field, so the server rejects the request (it requires the field on a PATCH withoutupdate_mask) instead of turning the setting off.backfill createwithout--run-on-latest-version/--no-run-on-latest-versionno longer sendsrun_on_latest_version=false. The server now resolves it (the Dag'srerun_with_latest_version, then[core] rerun_with_latest_version, thenTruefor 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-versionkeeps the old behavior.related: #73768
related: #73931 (a server-side change that would let
pools updatesend 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.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 mergingmain). The new cases for a bare/conflictingdags update, an omittedpools update --include-deferred, an omittedbackfill create --run-on-latest-version, and thedags updaterequest body fail without the change; the explicit-flag cases pin that--is-paused/--no-is-paused,--include-deferred/--no-include-deferredand--run-on-latest-version/--no-run-on-latest-versionstill sendTrue/False.prekmypy-airflow-ctlhook (run on commit): passed.pools updatecommand in theairflow-ctl-testsintegration list now passes--no-include-deferredexplicitly, because the server requires the field on a PATCH withoutupdate_mask. I did not run the integration tests locally (they need a Docker Compose stack).airflowctl <command> --helpoutput fordags update,dags trigger,pools create,pools update,backfill createandtasks clearis identical with and without the change, so the help images are unaffected.generate-airflowctl-help-imageswas skipped locally because it needs breeze.No newsfragment, because airflow-ctl doesn't use them.
airflow-ctl/RELEASE_NOTES.rstis 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?
Generated-by: GitHub Copilot CLI (Claude Opus 5.5) following the guidelines
{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.