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

   ## Summary
   
   The set_xcom endpoint in the Execution API catches ValueError from
   XComModel.set_for_attempt and re-raises it as an HTTPException, but passes
   the error message as a bare string rather than the structured dict expected 
by
   RFC 9457:
   
   `python
   # before (non-compliant)
   except ValueError as e:
       raise HTTPException(status.HTTP_404_NOT_FOUND, str(e))
   `
   
   Every other error handler in xcoms.py already uses the RFC 9457 schema
   ( eason + message keys). This patch makes the ValueError case
   consistent with the rest of the router:
   
   `python
   # after (RFC 9457-compliant)
   except ValueError as e:
       raise HTTPException(
           status_code=status.HTTP_404_NOT_FOUND,
           detail={'reason': 'not_found', 'message': str(e)},
       )
   `
   
   A unit test using unittest.mock.patch verifies that the endpoint returns a
   404 response whose detail field is a dict with the  eason and message
   keys when XComModel.set_for_attempt raises ValueError.
   
   Closes #70044
   
   ## Checklist
   
   - [x] My PR title and commit message follow [conventional 
commits](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#conventional-commits)
   - [x] I have added tests that prove my fix is effective or that my feature 
works
   - [x] I have made corresponding changes to the documentation (N/A for this 
bug fix)
   - [x] My changes generate no new warnings
   - [x] My code follows the [style 
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/16_contribution_workflow.rst)
 of this project
   - [x] I have signed off my commit (git commit -s) in accordance with the 
[DCO](https://developercertificate.org/)


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