This is an automated email from the ASF dual-hosted git repository.
Lee-W pushed a commit to branch v3-3-test
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/v3-3-test by this push:
new 99f0aae863d [v3-3-test] Raise when attaching partition keys to asset
alias events (#69312) (#69515)
99f0aae863d is described below
commit 99f0aae863d46ebdbc0fef1e3e9b00251818274b
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Wed Jul 8 11:43:59 2026 +0800
[v3-3-test] Raise when attaching partition keys to asset alias events
(#69312) (#69515)
Co-authored-by: Wei Lee <[email protected]>
---
task-sdk/src/airflow/sdk/execution_time/context.py | 7 +++++++
task-sdk/tests/task_sdk/execution_time/test_context.py | 8 ++++++++
2 files changed, 15 insertions(+)
diff --git a/task-sdk/src/airflow/sdk/execution_time/context.py
b/task-sdk/src/airflow/sdk/execution_time/context.py
index d41306009ea..cd8941944b6 100644
--- a/task-sdk/src/airflow/sdk/execution_time/context.py
+++ b/task-sdk/src/airflow/sdk/execution_time/context.py
@@ -977,7 +977,14 @@ class OutletEventAccessor(_AssetRefResolutionMixin):
:raises ValueError: If any key is empty/whitespace-only or longer than
``_PARTITION_KEY_MAX_LENGTH`` characters.
+ :raises TypeError: If this accessor is for an asset alias, since
partition
+ keys are only attached to concrete asset events, not alias events.
"""
+ if isinstance(self.key, AssetAliasUniqueKey):
+ raise TypeError(
+ "add_partitions() is not supported on asset alias outlet
events; "
+ "partition keys can only be attached to a concrete asset."
+ )
if isinstance(keys, str):
keys = [keys]
for key in keys:
diff --git a/task-sdk/tests/task_sdk/execution_time/test_context.py
b/task-sdk/tests/task_sdk/execution_time/test_context.py
index eb1ffa0013e..fd40feb571f 100644
--- a/task-sdk/tests/task_sdk/execution_time/test_context.py
+++ b/task-sdk/tests/task_sdk/execution_time/test_context.py
@@ -536,6 +536,14 @@ class TestOutletEventAccessorPartitionKeys:
accessor.add_partitions(["us", ""])
assert accessor.partition_keys == set()
+ def test_add_partitions_rejects_asset_alias_accessor(self):
+ alias_accessor = OutletEventAccessor(
+ key=AssetAliasUniqueKey.from_asset_alias(AssetAlias("test_alias"))
+ )
+ with pytest.raises(TypeError, match="not supported on asset alias"):
+ alias_accessor.add_partitions("us")
+ assert alias_accessor.partition_keys == set()
+
class TestTriggeringAssetEventsAccessor:
@pytest.fixture(autouse=True)