Brunda10 opened a new pull request, #56042:
URL: https://github.com/apache/airflow/pull/56042

   **Title**
   
   Fix XCom key handling when keys contain special characters like /
   
   **Summary**
   
   This PR fixes an issue where XCom keys containing special characters (for 
example /) would break API calls and cause 404 Not Found errors.
   
   The problem happened because keys were passed directly in the URL without 
encoding, so FastAPI treated / as a path separator.
   
   **Changes Made**
   
   _SDK (client.py, taskrunner.py)_
   
   - Keys are now URL-encoded (quoted) before sending them to the API.
   - When pulling XComs, keys are properly decoded and a default value is 
returned if nothing is found.
   - Multi-output dict keys from tasks are also encoded before push.
   
   _APIs (core_api/routes/public/xcoms.py, execution_api/routes/xcoms.py)_
   
   - Keys from the URL are now decoded (unquoted) before looking them up in the 
database.
   - Improved error handling and responses when XComs are missing.
   - Added consistent behavior for mapped/unmapped tasks.
   
   **This PR ensures:**
   
   - Keys are always quoted when sent (safe for URLs).
   
   - Keys are always unquoted when received (correct DB lookup).
   
   - Aligns XCom behavior across different access points (UI, API, execution 
API, and task runner).
   
   **Testing:**
   ```
   from airflow.decorators import dag, task
   
   @dag(schedule=None)
   def xcom_slash():
   
       @task
       def this_works() -> dict[str, str]:
           return {"Some Key": "Some Value"}
       @task
       def this_works_as_well() -> str:
           return "/some/path/like/key"
   
       @task
       def this_does_not_work() -> dict[str, str]:
           return {"key with slash /": "Some Value"}
   
       this_works() >> this_works_as_well() >> this_does_not_work()
   
   dag = xcom_slash() 
   ``` 


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