qcha41 opened a new issue, #27007:
URL: https://github.com/apache/airflow/issues/27007
### Apache Airflow version
Other Airflow 2 version
### What happened
Hello everyone,
I am trying to use a custom XCOM key in task mapping, other than the default
"return_value" key. This results in a ValueError :
```
ValueError: cannot map over XCom with custom key [...]
```
### What you think should happen instead
I don't understand this limitation.
### How to reproduce
```python
import datetime as dt
from airflow import DAG, XComArg
from airflow.operators.trigger_dagrun import TriggerDagRunOperator
from airflow.operators.python import PythonOperator
with DAG(
'dag_test_v1.0.0',
start_date = dt.datetime(2022, 10, 12),
) as dag:
def produce_parameters(**kwargs):
kwargs['ti'].xcom_push("my_custom_key", [{"message":1},
{"message":2}])
t1 = PythonOperator(task_id='python_task',
python_callable=produce_parameters, provide_context=True,)
t2 = TriggerDagRunOperator.partial(
task_id = 'task2',
trigger_dag_id = 'sandbox_downstream_v1.0.1'
).expand(
conf=XComArg(t1, 'my_custom_key')
)
t1 >> t2
```
```
Traceback (most recent call last):
File "dag_test.py", line 17, in <module>
t2 = TriggerDagRunOperator.partial(
File
"/usr/local/lib/python3.10/site-packages/airflow/models/mappedoperator.py",
line 179, in expand
return self._expand(DictOfListsExpandInput(mapped_kwargs), strict=False)
File
"/usr/local/lib/python3.10/site-packages/airflow/models/mappedoperator.py",
line 196, in _expand
ensure_xcomarg_return_value(expand_input.value)
File
"/usr/local/lib/python3.10/site-packages/airflow/models/mappedoperator.py",
line 133, in ensure_xcomarg_return_value
ensure_xcomarg_return_value(v)
File
"/usr/local/lib/python3.10/site-packages/airflow/models/mappedoperator.py",
line 128, in ensure_xcomarg_return_value
raise ValueError(f"cannot map over XCom with custom key {key!r} from
{operator}")
ValueError: cannot map over XCom with custom key 'my_custom_key' from
<Task(PythonOperator): python_task>
```bash
### Operating System
Debian 11
### Versions of Apache Airflow Providers
_No response_
### Deployment
Virtualenv installation
### 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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]