You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "vatsrahul1001 (via GitHub)" <gi...@apache.org> on 2025/03/14 11:02:05 UTC

[I] Mapped Asset Alias task failing [airflow]

vatsrahul1001 opened a new issue, #47779:
URL: https://github.com/apache/airflow/issues/47779

   ### Apache Airflow version
   
   main (development)
   
   ### If "Other Airflow 2 version" selected, which one?
   
   _No response_
   
   ### What happened?
   
   Mapped Asset Alias task failing
   <img width="1654" alt="Image" src="https://github.com/user-attachments/assets/22724965-c182-4fa5-8c4d-eecd3bc9f5c1" />
   
   
   **Error**
   [2025-03-14, 10:48:23] ERROR - Task failed with exception source="task" error_detail=[{"exc_type":"TypeError","exc_value":"Key should be either an asset or an asset alias, not <class 'str'>","syntax_error":null,"is_cause":false,"frames":[{"filename":"/opt/airflow/task-sdk/src/airflow/sdk/execution_time/task_runner.py","lineno":609,"name":"run"},{"filename":"/opt/airflow/task-sdk/src/airflow/sdk/execution_time/task_runner.py","lineno":734,"name":"_execute_task"},{"filename":"/opt/airflow/task-sdk/src/airflow/sdk/definitions/baseoperator.py","lineno":373,"name":"wrapper"},{"filename":"/opt/airflow/airflow/decorators/base.py","lineno":252,"name":"execute"},{"filename":"/opt/airflow/task-sdk/src/airflow/sdk/definitions/baseoperator.py","lineno":373,"name":"wrapper"},{"filename":"/opt/airflow/providers/standard/src/airflow/providers/standard/operators/python.py","lineno":196,"name":"execute"},{"filename":"/opt/airflow/providers/standard/src/airflow/providers/standard/operators/python.p
 y","lineno":220,"name":"execute_callable"},{"filename":"/opt/airflow/airflow/utils/operator_helpers.py","lineno":274,"name":"run"},{"filename":"/opt/airflow/task-sdk/src/airflow/sdk/execution_time/context.py","lineno":238,"name":"__getitem__"}]}]
   
   
   ### What you think should happen instead?
   
   _No response_
   
   ### How to reproduce
   
   Try running below DAG. This used to work in AF2
   
   ```
   
   from airflow.decorators import dag, task
   from airflow.datasets import Dataset, DatasetAlias
   from airflow.sdk.definitions.asset.metadata import Metadata
   from pendulum import datetime
   
   my_alias_name = "alias-dataset-1"
   
   
   @dag(
       dag_display_name="example_dataset_alias_mapped",
       start_date=datetime(2024, 8, 1),
       schedule=None,
       catchup=False,
       tags=["datasets"],
   )
   def dataset_alias_dynamic_test():
       @task
       def upstream_task():
           return ["a", "b"]
   
       @task(outlets=[DatasetAlias(my_alias_name)])
       def use_metadata(name):
           yield Metadata(
               Dataset(name),
               alias=my_alias_name,
               extra={}  # extra is NOT optional
           )
   
       use_metadata.expand(name=upstream_task())
   
   
   dataset_alias_dynamic_test()
   
   
   @dag(
       start_date=datetime(2024, 8, 1),
       schedule=[DatasetAlias(my_alias_name)],
       catchup=False,
       tags=["dataset"]
   )
   def downstream_alias():
       @task
       def t1():
           return 0
   
       t1()
   
   
   downstream_alias()
   ```
   
   ### Operating System
   
   linux
   
   ### Versions of Apache Airflow Providers
   
   _No response_
   
   ### Deployment
   
   Other
   
   ### Deployment details
   
   _No response_
   
   ### Anything else?
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
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: commits-unsubscribe@airflow.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Regression] Argument 'extra' should be optional when pushing metadata to alias [airflow]

Posted by "uranusjr (via GitHub)" <gi...@apache.org>.
uranusjr commented on issue #47779:
URL: https://github.com/apache/airflow/issues/47779#issuecomment-2746064106

   This should be a separate issue. The one described in this has been fixed.


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Regression] Argument 'extra' should be optional when pushing metadata to alias [airflow]

Posted by "atul-astronomer (via GitHub)" <gi...@apache.org>.
atul-astronomer commented on issue #47779:
URL: https://github.com/apache/airflow/issues/47779#issuecomment-2743163921

   @Lee-W The error is that Asset is not active but I see there is no Asset created (A or B) in DB and there is no duplicate name or uri.


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Regression] Argument 'extra' should be optional when pushing metadata to alias [airflow]

Posted by "atul-astronomer (via GitHub)" <gi...@apache.org>.
atul-astronomer commented on issue #47779:
URL: https://github.com/apache/airflow/issues/47779#issuecomment-2747245701

   Thanks @Lee-W , working after refactoring Dag code


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Mapped Asset Alias task failing [airflow]

Posted by "vatsrahul1001 (via GitHub)" <gi...@apache.org>.
vatsrahul1001 commented on issue #47779:
URL: https://github.com/apache/airflow/issues/47779#issuecomment-2726300039

   > Maybe we should make extra optional here though. Was it required in 2.x?
   
   Same DAG is working in 2.x


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Mapped Asset Alias task failing [airflow]

Posted by "uranusjr (via GitHub)" <gi...@apache.org>.
uranusjr commented on issue #47779:
URL: https://github.com/apache/airflow/issues/47779#issuecomment-2726243717

   Maybe we should make extra optional here though. Was it required in 2.x?


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Regression] Argument 'extra' should be optional when pushing metadata to alias [airflow]

Posted by "atul-astronomer (via GitHub)" <gi...@apache.org>.
atul-astronomer commented on issue #47779:
URL: https://github.com/apache/airflow/issues/47779#issuecomment-2742979812

   Same Dag given in description is still failing:
   @Lee-W @uranusjr 
   
    "/usr/local/lib/python3.9/site-packages/cadwyn/structure/versions.py", line 521, in _convert_endpoint_response_to_version
       response_or_response_body: Union[FastapiResponse, object] = await run_in_threadpool(
     File "/usr/local/lib/python3.9/site-packages/starlette/concurrency.py", line 37, in run_in_threadpool
       return await anyio.to_thread.run_sync(func)
     File "/usr/local/lib/python3.9/site-packages/anyio/to_thread.py", line 56, in run_sync
       return await get_async_backend().run_sync_in_worker_thread(
     File "/usr/local/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 2470, in run_sync_in_worker_thread
       return await future
     File "/usr/local/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 967, in run
       result = context.run(func, *args)
     File "/usr/local/lib/python3.9/site-packages/cadwyn/schema_generation.py", line 502, in __call__
       return self._original_callable(*args, **kwargs)
     File "/opt/airflow/airflow/api_fastapi/execution_api/routes/task_instances.py", line 314, in ti_update_state
       TI.register_asset_changes_in_db(
     File "/opt/airflow/airflow/utils/session.py", line 98, in wrapper
       return func(*args, **kwargs)
     File "/opt/airflow/airflow/models/taskinstance.py", line 2824, in register_asset_changes_in_db
       raise AirflowInactiveAssetAddedToAssetAliasException(bad_alias_asset_keys)
   


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Regression] Argument 'extra' should be optional when pushing metadata to alias [airflow]

Posted by "atul-astronomer (via GitHub)" <gi...@apache.org>.
atul-astronomer commented on issue #47779:
URL: https://github.com/apache/airflow/issues/47779#issuecomment-2747206952

   @Lee-W I am getting same error for which this issue was reported in couple of other Dag also, can you please check?
   
   ```python
   from __future__ import annotations
   
   import pendulum
   
   from airflow.sdk import DAG
   from airflow.datasets import Dataset, DatasetAlias
   from airflow.decorators import task
   from airflow.sdk import Asset
   
   with DAG(
       dag_id="dataset_alias_example_alias_producer",
       start_date=pendulum.datetime(2021, 1, 1, tz="UTC"),
       schedule=None,
       catchup=False,
       tags=["dataset"],
   ):
   
       @task(outlets=[DatasetAlias("example-alias")])
       def produce_dataset_events_through_dataset_alias(*, outlet_events=None):
           bucket_name = "bucket"
           object_path = "my-task"
           outlet_events["example-alias"].add(Asset(f"s3://{bucket_name}/{object_path}"))
   
       produce_dataset_events_through_dataset_alias()
   ``` 
   
   ERROR - Task failed with exception source="task" error_detail=[{"exc_type":"TypeError","exc_value":"Key should be either an asset or an asset alias, not <class 'str'>","exc_notes":[],"syntax_error":null,"is_cause":false,"frames":[{"filename":"/opt/airflow/task-sdk/src/airflow/sdk/execution_time/task_runner.py","lineno":614,"name":"run"},{"filename":"/opt/airflow/task-sdk/src/airflow/sdk/execution_time/task_runner.py","lineno":839,"name":"_execute_task"},{"filename":"/opt/airflow/task-sdk/src/airflow/sdk/definitions/baseoperator.py","lineno":377,"name":"wrapper"},{"filename":"/opt/airflow/airflow-core/src/airflow/decorators/base.py","lineno":252,"name":"execute"},{"filename":"/opt/airflow/task-sdk/src/airflow/sdk/definitions/baseoperator.py","lineno":377,"name":"wrapper"},{"filename":"/opt/airflow/providers/standard/src/airflow/providers/standard/operators/python.py","lineno":202,"name":"execute"},{"filename":"/opt/airflow/providers/standard/src/airflow/providers/standard/operators
 /python.py","lineno":226,"name":"execute_callable"},{"filename":"/opt/airflow/airflow-core/src/airflow/utils/operator_helpers.py","lineno":161,"name":"run"},{"filename":"/files/dags/datasets/2.10dags/example_dataset_alias.py","lineno":55,"name":"produce_dataset_events_through_dataset_alias"},{"filename":"/opt/airflow/task-sdk/src/airflow/sdk/execution_time/context.py","lineno":319,"name":"__getitem__"}]}]
   
   <img width="583" alt="Image" src="https://github.com/user-attachments/assets/5cf01e25-1029-4317-ae2d-ffbc32d8b8bb" />


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Mapped Asset Alias task failing [airflow]

Posted by "vatsrahul1001 (via GitHub)" <gi...@apache.org>.
vatsrahul1001 commented on issue #47779:
URL: https://github.com/apache/airflow/issues/47779#issuecomment-2724341054

   cc: @uranusjr @Lee-W 


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Regression]Mapped Asset Alias task failing [airflow]

Posted by "phanikumv (via GitHub)" <gi...@apache.org>.
phanikumv commented on issue #47779:
URL: https://github.com/apache/airflow/issues/47779#issuecomment-2731832282

   @rawwar need your help to fix this


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Regression]Mapped Asset Alias task failing [airflow]

Posted by "rawwar (via GitHub)" <gi...@apache.org>.
rawwar commented on issue #47779:
URL: https://github.com/apache/airflow/issues/47779#issuecomment-2731845963

   > [@rawwar](https://github.com/rawwar) need your help to fix this
   
   I will work on this.


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Regression] Argument 'extra' should be optional when pushing metadata to alias [airflow]

Posted by "kaxil (via GitHub)" <gi...@apache.org>.
kaxil closed issue #47779: [Regression] Argument 'extra' should be optional when pushing metadata to alias
URL: https://github.com/apache/airflow/issues/47779


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Regression] Argument 'extra' should be optional when pushing metadata to alias [airflow]

Posted by "Lee-W (via GitHub)" <gi...@apache.org>.
Lee-W commented on issue #47779:
URL: https://github.com/apache/airflow/issues/47779#issuecomment-2743010741

   > Same Dag given in description is still failing: [@Lee-W](https://github.com/Lee-W) [@uranusjr](https://github.com/uranusjr)
   > 
   > "/usr/local/lib/python3.9/site-packages/cadwyn/structure/versions.py", line 521, in _convert_endpoint_response_to_version response_or_response_body: Union[FastapiResponse, object] = await run_in_threadpool( File "/usr/local/lib/python3.9/site-packages/starlette/concurrency.py", line 37, in run_in_threadpool return await anyio.to_thread.run_sync(func) File "/usr/local/lib/python3.9/site-packages/anyio/to_thread.py", line 56, in run_sync return await get_async_backend().run_sync_in_worker_thread( File "/usr/local/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 2470, in run_sync_in_worker_thread return await future File "/usr/local/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 967, in run result = context.run(func, *args) File "/usr/local/lib/python3.9/site-packages/cadwyn/schema_generation.py", line 502, in **call** return self._original_callable(*args, **kwargs) File "/opt/airflow/airflow/api_fastapi/execution_api/routes/task_instances.py", line 31
 4, in ti_update_state TI.register_asset_changes_in_db( File "/opt/airflow/airflow/utils/session.py", line 98, in wrapper return func(*args, **kwargs) File "/opt/airflow/airflow/models/taskinstance.py", line 2824, in register_asset_changes_in_db raise AirflowInactiveAssetAddedToAssetAliasException(bad_alias_asset_keys)
   
   Is the asset active? (referenced somewhere and has no duplicate name or uri) If not, this is expected behavior as stated https://github.com/apache/airflow/issues/47779#issuecomment-2724389162


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Mapped Asset Alias task failing [airflow]

Posted by "Lee-W (via GitHub)" <gi...@apache.org>.
Lee-W commented on issue #47779:
URL: https://github.com/apache/airflow/issues/47779#issuecomment-2724389162

   It should be 
   
   ```python
           yield Metadata(
               Dataset(name),
               alias=DatasetAlias(my_alias_name),
               extra={}  # extra is NOT optional
           )
   ```
   
   now. But after changing it, we still encounter the issue that `Dataset("a"), Dataset("b")` has not yet been activated. @uranusjr If my memory serves me right, we decided not to allow this (create asset event to asset that has not yet been activated.). If that's the case, we probably should be just close this one


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Regression] Argument 'extra' should be optional when pushing metadata to alias [airflow]

Posted by "kaxil (via GitHub)" <gi...@apache.org>.
kaxil closed issue #47779: [Regression] Argument 'extra' should be optional when pushing metadata to alias
URL: https://github.com/apache/airflow/issues/47779


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Regression] Argument 'extra' should be optional when pushing metadata to alias [airflow]

Posted by "Lee-W (via GitHub)" <gi...@apache.org>.
Lee-W commented on issue #47779:
URL: https://github.com/apache/airflow/issues/47779#issuecomment-2746244002

   > @Lee-W The error is that Asset is not active but I see there is no Asset created (A or B) in DB and there is no duplicate name or uri.
   
   @uranusjr are we going to support this in AF3? I thought we decide not?
   
   @atul-astronomer but yep, whether we decide to support it or not. that not for this issue. closing it


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Regression] Argument 'extra' should be optional when pushing metadata to alias [airflow]

Posted by "Lee-W (via GitHub)" <gi...@apache.org>.
Lee-W closed issue #47779: [Regression] Argument 'extra' should be optional when pushing metadata to alias
URL: https://github.com/apache/airflow/issues/47779


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Regression] Argument 'extra' should be optional when pushing metadata to alias [airflow]

Posted by "Lee-W (via GitHub)" <gi...@apache.org>.
Lee-W commented on issue #47779:
URL: https://github.com/apache/airflow/issues/47779#issuecomment-2747211687

   `outlet_events["example-alias"].add(Asset(f"s3://{bucket_name}/{object_path}"))` should be `outlet_events[AssetAlias("example-alias")]` instead


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org