phanikumv commented on code in PR #77759:
URL: https://github.com/apache/airflow/pull/77759#discussion_r4765652197


##########
task-sdk/src/airflow/sdk/execution_time/callback_runner.py:
##########
@@ -26,12 +26,26 @@
 if TYPE_CHECKING:
     from structlog.typing import FilteringBoundLogger as Logger
 
+    from airflow.sdk.definitions.asset.metadata import Metadata
     from airflow.sdk.types import OutletEventAccessorsProtocol
 
 P = ParamSpec("P")
 R = TypeVar("R")
 
 
+def _record_metadata(outlet_events: OutletEventAccessorsProtocol, metadata: 
Metadata) -> None:
+    from airflow.sdk.exceptions import UndeclaredOutletError
+
+    try:
+        outlet_events[metadata.asset].extra.update(metadata.extra)
+    except UndeclaredOutletError:

Review Comment:
   `yield Metadata(..., alias=...)` now fails where it used to work.
   
   Take a task with `outlets=[Asset(name="raw", uri="s3://b/x"), 
AssetAlias("al")]`
     • `outlet_events[AssetAlias("al")].add(Asset("s3://b/x"))` still records 
the alias event.
     • `yield Metadata(Asset("s3://b/x"), alias=AssetAlias("al"))` now raises 
`ConflictingOutletError`, because `_record_metadata` only catches 
`UndeclaredOutletError`
   
   Before this PR, core stored that alias event (it only warns the asset is 
inactive, `assets/manager.py:290-317`) and queued Dags scheduled on the alias 
(`manager.py:322-350`). `raw` also got its own event. 
   
   Such a Dag now fails after upgrade, while the newsfragment (lines 17-18), 
the new line in `assets.rst` and the `Metadata` docstring say it keeps working.
   
   Fix: catch `InvalidOutletError` when `alias` is set, so the `Metadata` path 
behaves like `add()`, and flip 
`test_executable_runner_rejects_conflicting_asset_through_alias` to assert the 
event is recorded.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to