jgoedeke opened a new issue, #56882:
URL: https://github.com/apache/airflow/issues/56882
### Apache Airflow version
Other Airflow 2/3 version (please specify below)
### If "Other Airflow 2/3 version" selected, which one?
3.0.6
### What happened?
When using **TaskFlow-style asset event emission** with `yield
Metadata(...)`, the task fails if `extra` contains a **nested dict** (e.g.,
`{"nested": {"key": "value"}}`).
Flat dicts work fine.
Operator-style mutation of `outlet_events[...]` **does accept nested
dicts**, and JSON-encoding the nested portion also works.
The failure occurs after the function completes—likely during serialization
or persistence of the asset event—so logs look normal until teardown.
### What you think should happen instead?
`Metadata.extra` should accept any JSON-compatible structure, including
nested dicts, as documented. Nested dicts are valid JSON and should not cause
task failure.
### How to reproduce
```python
import json
from airflow.sdk import Asset, AssetAlias, dag, task
from airflow.sdk.definitions.asset.metadata import Metadata
@dag(schedule=None, tags=['test'])
def test_metadata_extra_nested():
@task(outlets=[AssetAlias('dummy_asset_alias')])
def working():
asset_name = 'dummy_asset'
yield Metadata(
asset=Asset(asset_name),
alias=AssetAlias('dummy_asset_alias'),
extra={'key': 'value'}, # works (flat)
)
return asset_name
@task(outlets=[AssetAlias('dummy_asset_alias')])
def task_flow_not_working():
asset_name = 'dummy_asset'
yield Metadata(
asset=Asset(asset_name),
alias=AssetAlias('dummy_asset_alias'),
extra={'nested': {'key': 'value'}}, # fails (nested)
)
return asset_name
@task(outlets=[AssetAlias('dummy_asset_alias')])
def working_with_flat_workaround():
asset_name = 'dummy_asset'
yield Metadata(
asset=Asset(asset_name),
alias=AssetAlias('dummy_asset_alias'),
extra={'nested': json.dumps({'key': 'value'})}, # workaround
)
return asset_name
@task(outlets=[AssetAlias('dummy_asset_alias')])
def operator_style_working_with_nested(outlet_events=None):
asset_name = 'dummy_asset'
outlet_events[AssetAlias('dummy_asset_alias')].add(Asset(asset_name))
outlet_events[AssetAlias('dummy_asset_alias')].extra = {
'nested': {'key': 'value'} # works in operator-style
}
return asset_name
working()
task_flow_not_working()
working_with_flat_workaround()
operator_style_working_with_nested()
test_metadata_extra_nested()
```
### Operating System
Docker compose
### Versions of Apache Airflow Providers
_No response_
### Deployment
Docker-Compose
### Deployment details
_No response_
### Anything else?
This may be related to https://github.com/apache/airflow/issues/53474
### 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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]