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

   ### Apache Airflow version
   
   main (development)
   
   ### If "Other Airflow 2 version" selected, which one?
   
   _No response_
   
   ### What happened?
   
   having `context["ti"].xcom_push(key="number_of_people_in_space", 
value=None)` in a task will fail with below error. I tested the same in AF2 and 
it works without issues. 
   
   ```
   [2025-08-29, 15:46:18] ERROR - Task failed with exception: source="task"
   AirflowRuntimeError: API_SERVER_ERROR: {'status_code': 422, 'message': 
'Remote server returned validation error', 'detail': {'detail': [{'type': 
'missing', 'loc': ['body'], 'msg': 'Field required', 'input': None}]}}
   
   File "/opt/airflow/task-sdk/src/airflow/sdk/execution_time/task_runner.py", 
line 920 in run
   
   File "/opt/airflow/task-sdk/src/airflow/sdk/execution_time/task_runner.py", 
line 1302 in _execute_task
   
   File "/opt/airflow/task-sdk/src/airflow/sdk/bases/operator.py", line 414 in 
wrapper
   
   File "/opt/airflow/task-sdk/src/airflow/sdk/bases/decorator.py", line 252 in 
execute
   
   File "/opt/airflow/task-sdk/src/airflow/sdk/bases/operator.py", line 414 in 
wrapper
   
   File 
"/opt/airflow/providers/standard/src/airflow/providers/standard/operators/python.py",
 line 216 in execute
   
   File 
"/opt/airflow/providers/standard/src/airflow/providers/standard/operators/python.py",
 line 239 in execute_callable
   
   File 
"/opt/airflow/task-sdk/src/airflow/sdk/execution_time/callback_runner.py", line 
82 in run
   
   File "/files/dags/aa.py", line 75 in get_astronauts
   
   File "/opt/airflow/task-sdk/src/airflow/sdk/execution_time/task_runner.py", 
line 414 in xcom_push
   
   File "/opt/airflow/task-sdk/src/airflow/sdk/execution_time/task_runner.py", 
line 561 in _xcom_push
   
   File "/opt/airflow/task-sdk/src/airflow/sdk/bases/xcom.py", line 86 in set
   
   File "/opt/airflow/task-sdk/src/airflow/sdk/execution_time/comms.py", line 
207 in send
   
   File "/opt/airflow/task-sdk/src/airflow/sdk/execution_time/comms.py", line 
271 in _get_response
   
   File "/opt/airflow/task-sdk/src/airflow/sdk/execution_time/comms.py", line 
258 in _from_frame
   ```
   
   ### What you think should happen instead?
   
   It should created an XCOM with the given key and value set to None
   
   ### How to reproduce
   
   ```
   
   from airflow.sdk.definitions.asset import Asset
   from airflow.decorators import dag, task
   from pendulum import datetime
   import requests
   
   
   # Define the basic parameters of the DAG, like schedule and start_date
   @dag(
       start_date=datetime(2024, 1, 1),
       schedule="@daily",
       catchup=False,
       doc_md=__doc__,
       default_args={"owner": "Astro", "retries": 3},
       tags=["example"],
   )
   def example_astronauts():
       # Define tasks
       @task(
           # Define a dataset outlet for the task. This can be used to schedule 
downstream DAGs when this task has run.
           outlets=[Asset("current_astronauts")]
       )  # Define that this task updates the `current_astronauts` Dataset
       def get_astronauts(**context) -> list[dict]:
           context["ti"].xcom_push(
               key="number_of_people_in_space", value=None
           )
           return [{"craft": "ISS", "name": "Oleg Kononenko"},]
   
       @task
       def print_astronaut_craft(greeting: str, person_in_space: dict) -> None:
   
           craft = person_in_space["craft"]
           name = person_in_space["name"]
   
           print(f"{name} is currently in space flying on the {craft}! 
{greeting}")
   
       # Use dynamic task mapping to run the print_astronaut_craft task for each
       # Astronaut in space
       print_astronaut_craft.partial(greeting="Hello! :)").expand(
           person_in_space=get_astronauts()  # Define dependencies using 
TaskFlow API syntax
       )
   
   
   # Instantiate the DAG
   example_astronauts()
   
   ```
   
   ### Operating System
   
   macos
   
   ### Versions of Apache Airflow Providers
   
   _No response_
   
   ### Deployment
   
   Astronomer
   
   ### Deployment details
   
   _No response_
   
   ### Anything else?
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [x] 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]

Reply via email to