Repository navigation
Read XCom without object reconstruction during dependency evaluation - #72718
Merged
Merged
Conversation
potiuk
force-pushed
the
scheduler-xcom-dep-primitives-only
branch
from
September 24, 2026 18:04
e4dd5a2 to
91bc375
Compare
Member
Author
potiuk
force-pushed
the
scheduler-xcom-dep-primitives-only
branch
from
October 4, 2026 23:33
91bc375 to
d75eb9a
Compare
The scheduler evaluates task dependencies in-process, and two of those deps read XCom: NotPreviouslySkippedDep reads skipmixin_key for every parent that inherits from SkipMixin, and both it and TriggerRuleDep read past_depends_met when wait_for_past_depends_before_skipping applies. Both went through TaskInstance.xcom_pull -> XComModel.deserialize_value, which is json.loads(value, cls=XComDecoder). XComDecoder's object_hook calls the Airflow serialization module with full=True, so any nested dict carrying __classname__ is imported and instantiated. The values these deps actually consume are primitives: a mapping of lists of task ids, and a boolean. Nothing here needs an object rebuilt, so the scheduler can read these values as plain JSON. Add XComModel.deserialize_value_primitives, a plain json.loads with no object_hook, and LazyXComPrimitivesSelectSequence alongside it. Thread full=True through TaskInstance.xcom_pull and pass full=False at the four dep call sites. All three of xcom_pull's return paths are covered -- the direct one, and both lazy-sequence ones, which is the path a mapped task instance takes. The skip decisions of SkipMixin tasks in the same mapped task group, which NotPreviouslySkippedDep reads with one query per pass, are decoded the same way. NotPreviouslySkippedDep also now checks that the skipmixin payload is a mapping before testing membership in it. It reads whatever the parent task wrote, so a scalar there previously raised TypeError inside dependency evaluation rather than being ignored. Because the payload is now plain JSON, a set or tuple of task ids arrives as its serde wrapper; its items are read from the wrapper without constructing anything, and a decision whose task ids are not a list of strings is ignored the same way. Task code pulling another task's return value is unchanged and still gets the original Python object; only the dependency-evaluation reads are narrowed. Generated-by: Claude Opus 5
potiuk
force-pushed
the
scheduler-xcom-dep-primitives-only
branch
from
October 15, 2026 22:52
d75eb9a to
ca8ef2d
Compare
1 task done
…ation Generated-by: Claude Opus 5 following the guidelines at https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions
Member
Author
Generated-by: Claude Opus 5
vatsrahul1001
approved these changes
Oct 18, 2026
Contributor
Backport successfully created: v3-4-testNote: As of Merging PRs targeted for Airflow 3.X In matter of doubt please ask in #release-management Slack channel.
|
potiuk
added a commit
that referenced
this pull request
Oct 19, 2026
… evaluation (#72718) (#75117) * Read XCom without object reconstruction during dependency evaluation The scheduler evaluates task dependencies in-process, and two of those deps read XCom: NotPreviouslySkippedDep reads skipmixin_key for every parent that inherits from SkipMixin, and both it and TriggerRuleDep read past_depends_met when wait_for_past_depends_before_skipping applies. Both went through TaskInstance.xcom_pull -> XComModel.deserialize_value, which is json.loads(value, cls=XComDecoder). XComDecoder's object_hook calls the Airflow serialization module with full=True, so any nested dict carrying __classname__ is imported and instantiated. The values these deps actually consume are primitives: a mapping of lists of task ids, and a boolean. Nothing here needs an object rebuilt, so the scheduler can read these values as plain JSON. Add XComModel.deserialize_value_primitives, a plain json.loads with no object_hook, and LazyXComPrimitivesSelectSequence alongside it. Thread full=True through TaskInstance.xcom_pull and pass full=False at the four dep call sites. All three of xcom_pull's return paths are covered -- the direct one, and both lazy-sequence ones, which is the path a mapped task instance takes. The skip decisions of SkipMixin tasks in the same mapped task group, which NotPreviouslySkippedDep reads with one query per pass, are decoded the same way. NotPreviouslySkippedDep also now checks that the skipmixin payload is a mapping before testing membership in it. It reads whatever the parent task wrote, so a scalar there previously raised TypeError inside dependency evaluation rather than being ignored. Because the payload is now plain JSON, a set or tuple of task ids arrives as its serde wrapper; its items are read from the wrapper without constructing anything, and a decision whose task ids are not a list of strings is ignored the same way. Task code pulling another task's return value is unchanged and still gets the original Python object; only the dependency-evaluation reads are narrowed. Generated-by: Claude Opus 5 * Treat only a literal True as past-depends-met during dependency evaluation Generated-by: Claude Opus 5 following the guidelines at https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions * Ignore skip decisions with a non-string classname (cherry picked from commit a7ac937) Generated-by: Claude Opus 5 Co-authored-by: Jarek Potiuk <[email protected]>
1 task done
vatsrahul1001
pushed a commit
that referenced
this pull request
Oct 20, 2026
… evaluation (#72718) (#75117) * Read XCom without object reconstruction during dependency evaluation The scheduler evaluates task dependencies in-process, and two of those deps read XCom: NotPreviouslySkippedDep reads skipmixin_key for every parent that inherits from SkipMixin, and both it and TriggerRuleDep read past_depends_met when wait_for_past_depends_before_skipping applies. Both went through TaskInstance.xcom_pull -> XComModel.deserialize_value, which is json.loads(value, cls=XComDecoder). XComDecoder's object_hook calls the Airflow serialization module with full=True, so any nested dict carrying __classname__ is imported and instantiated. The values these deps actually consume are primitives: a mapping of lists of task ids, and a boolean. Nothing here needs an object rebuilt, so the scheduler can read these values as plain JSON. Add XComModel.deserialize_value_primitives, a plain json.loads with no object_hook, and LazyXComPrimitivesSelectSequence alongside it. Thread full=True through TaskInstance.xcom_pull and pass full=False at the four dep call sites. All three of xcom_pull's return paths are covered -- the direct one, and both lazy-sequence ones, which is the path a mapped task instance takes. The skip decisions of SkipMixin tasks in the same mapped task group, which NotPreviouslySkippedDep reads with one query per pass, are decoded the same way. NotPreviouslySkippedDep also now checks that the skipmixin payload is a mapping before testing membership in it. It reads whatever the parent task wrote, so a scalar there previously raised TypeError inside dependency evaluation rather than being ignored. Because the payload is now plain JSON, a set or tuple of task ids arrives as its serde wrapper; its items are read from the wrapper without constructing anything, and a decision whose task ids are not a list of strings is ignored the same way. Task code pulling another task's return value is unchanged and still gets the original Python object; only the dependency-evaluation reads are narrowed. Generated-by: Claude Opus 5 * Treat only a literal True as past-depends-met during dependency evaluation Generated-by: Claude Opus 5 following the guidelines at https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions * Ignore skip decisions with a non-string classname (cherry picked from commit a7ac937) Generated-by: Claude Opus 5 Co-authored-by: Jarek Potiuk <[email protected]>
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.
The scheduler evaluates task dependencies in-process, and two of those deps read XCom:
NotPreviouslySkippedDepreadsskipmixin_keyfor every parent that inherits fromSkipMixin— any Branch or ShortCircuit operator, so this is a common path.TriggerRuleDepreadpast_depends_metwhenwait_for_past_depends_before_skippingapplies.Both went through
TaskInstance.xcom_pull→XComModel.deserialize_value, which isjson.loads(value, cls=XComDecoder).XComDecoder.object_hookcalls the serialization module withfull=True, so a nested dict carrying__classname__gets imported and instantiated.The values these deps actually consume are primitives — a mapping of lists of task ids, and a boolean. Nothing here needs an object rebuilt, so the scheduler can read them as plain JSON without reconstructing objects.
Change
XComModel.deserialize_value_primitives— plainjson.loads, noobject_hook. A__classname__envelope comes back as a plaindict.LazyXComPrimitivesSelectSequencealongsideLazyXComSelectSequence, for the lazy path.full: bool = Truethreaded throughTaskInstance.xcom_pull;full=Falseat the four dep call sites.All three of
xcom_pull's return paths are covered — the direct one and both lazy-sequence ones. The lazy path is what a mapped task instance takes, so covering only the direct return would have left mapped task instances on the old behaviour.NotPreviouslySkippedDepalso now checks the skipmixin payload is a mapping before testing membership. It reads whatever the parent task wrote, and a scalar there previously raisedTypeErrorinside dependency evaluation instead of being ignored.Task code pulling another task's return value is unchanged and still receives the original Python object. Only the scheduler-side dep reads are narrowed.
Tests
Two regression tests, both verified to fail on unpatched sources and pass with the change:
skipmixin_keyis read as a plain mapping rather than reconstructed;Both write through
XComModel.set(..., serialize=False)with a pre-serialized string, which is what the Execution API does with a caller-supplied value —serialize_valuewould have rejected the payload, so writing through that path would not exercise the case.Suites run after rebasing on current
main:test_not_previously_skipped_dep.py+test_trigger_rule_dep.py+models/test_xcom.py(211),test_taskinstance.py -k xcom(19). All pass.🤖 Generated with Claude Code
https://claude.ai/code/session_015DKYM5PoVgKC5JqxLso8rn