You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fix executor_config reference aliasing across tasks and DAGs (#72544) - #72563
_get_parent_defaults previously used copy.copy (shallow copy) when merging dag.default_args. This caused nested mutable structures, specifically executor_config, to be shared by object reference across all tasks and DAGs inheriting from those shared defaults. Consequently, runtime mutations to task.executor_config (such as setting Kubernetes pod overrides) silently modified sibling tasks and unrelated DAGs.
This PR updates _get_parent_defaults to use copy.deepcopy and explicitly deep-copies executor_config during BaseOperator initialization, ensuring strict reference isolation across task definitions.
Changes Made
task-sdk/src/airflow/sdk/bases/operator.py:
Replaced copy.copy(dag.default_args) with copy.deepcopy(dag.default_args) in _get_parent_defaults.
Updated self.executor_config assignment in BaseOperator.__init__ to use copy.deepcopy(executor_config) to isolate both explicit and inherited configurations.
Note: The failing Provider distributions tests / Compat CI jobs appear to be unrelated upstream matrix timeouts/flakes, as the changes in this PR are strictly isolated to task-sdk/src/airflow/sdk/bases/operator.py.
Closing this. Fixing the executor_config aliasing only needs that value copied, but this also switches _get_parent_defaults from copy.copy to copy.deepcopy for every default_args value, task-group defaults included. Values that can't be deep-copied then fail when the Dag is parsed: a default_args whose on_failure_callback is bound to an object holding a threading.Lock copies fine today and raises TypeError: cannot pickle '_thread.lock' object under deepcopy. There's also no test for the aliasing this sets out to fix.
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
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.
Description
Fixes #72544
_get_parent_defaultspreviously usedcopy.copy(shallow copy) when mergingdag.default_args. This caused nested mutable structures, specificallyexecutor_config, to be shared by object reference across all tasks and DAGs inheriting from those shared defaults. Consequently, runtime mutations totask.executor_config(such as setting Kubernetes pod overrides) silently modified sibling tasks and unrelated DAGs.This PR updates
_get_parent_defaultsto usecopy.deepcopyand explicitly deep-copiesexecutor_configduringBaseOperatorinitialization, ensuring strict reference isolation across task definitions.Changes Made
task-sdk/src/airflow/sdk/bases/operator.py:copy.copy(dag.default_args)withcopy.deepcopy(dag.default_args)in_get_parent_defaults.self.executor_configassignment inBaseOperator.__init__to usecopy.deepcopy(executor_config)to isolate both explicit and inherited configurations.