You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "amoghrajesh (via GitHub)" <gi...@apache.org> on 2025/12/04 08:23:12 UTC

[I] Correct xcom patch API to be usable with tasks [airflow]

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

   ### Body
   
   Context: https://github.com/apache/airflow/pull/58900#discussion_r2577456791
   
   If we use the xcom patch API to perform an update on an XCom via the PATCH API, you wouldn't really get a usable value out in the task.
   
   Ways to repro this:
   
   1. Define a dag like this:
   ```python
   from datetime import datetime
   
   from airflow.decorators import task
   from airflow.models.dag import DAG
   
   with DAG(dag_id="add_dag", schedule=None, start_date=datetime(2022, 3, 4)) as dag:
   
       @task
       def add_one(x: int):
           return x + 1
   
       @task
       def add_two(y: int):
           # y is result of add_one
           return y + 1
   
       @task
       def add_all_past_values(**context):
           xcoms = context['ti'].xcom_pull(task_ids=["add_one", "add_two"], include_prior_dates=True)
           print(xcoms)
   
   
       res1 = add_one(1)
       add_two(res1)
   
       add_all_past_values()
   
   ```
   
   2. Run the dag a couple times
   3. Identify a past run and update its xcom entry:
   ```shell script
   curl -X 'PATCH' \
     'http://localhost:28080/api/v2/dags/add_dag/dagRuns/manual__2025-12-02T07%3A34%3A26%2B00%3A00/taskInstances/add_one/xcomEntries/return_value' \
     -H 'accept: application/json' \
     -H 'Content-Type: application/json' \
     -d '{
     "value": 7,
     "map_index": -1
   }'
   ```
   
   4. Observe the output
   
   <img width="1125" height="305" alt="Image" src="https://github.com/user-attachments/assets/0334e3d3-ad22-4380-8642-5e70e2244dea" />
   
   Note the format of `7` from earlier patch, it is excessively serialised
   
   ### Committer
   
   - [x] I acknowledge that I am a maintainer/committer of the Apache Airflow project.


-- 
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] Correct xcom patch API to be usable with tasks [airflow]

Posted by "amoghrajesh (via GitHub)" <gi...@apache.org>.
amoghrajesh closed issue #59032: Correct xcom patch API to be usable with tasks
URL: https://github.com/apache/airflow/issues/59032


-- 
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] Correct xcom patch API to be usable with tasks [airflow]

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

   @sunank200 would you be working on 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] Correct xcom patch API to be usable with tasks [airflow]

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

   Thanks for picking up the issue.
   
   > Could you provide any additional context or point me to relevant code sections?
   
   The #58900 PR is a good point to get started with. Just FYI that the unit test for corresponding change will be located in `airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_xcom.py`.


-- 
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] Correct xcom patch API to be usable with tasks [airflow]

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

   Hi! I'm interested in working on this issue.
   
   I have experience with data engineering and would like to contribute. Could you provide any additional context or point me to relevant code sections?
   
   Thanks!


-- 
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