ashb commented on code in PR #46929:
URL: https://github.com/apache/airflow/pull/46929#discussion_r1963721913


##########
airflow/api_fastapi/execution_api/routes/xcoms.py:
##########
@@ -124,6 +124,18 @@ def get_xcom(
     map_index: Annotated[int, Query()] = -1,
 ) -> XComResponse:
     """Get an Airflow XCom from database - not other XCom Backends."""
+
+    # Validate that the provided key is not empty
+    # An empty key is not a valid XCom identifier and would lead to unintended 
queries
+    if not key:
+        raise HTTPException(
+            status_code=status.HTTP_400_BAD_REQUEST,
+            detail={
+                "reason": "invalid_key",
+                "message": "XCom key must be a non-empty string.",
+            },
+        )

Review Comment:
   Rather than doing this ourselves. lets let pydantic do this (and that way 
the requirement also shows up in the generated schema
   
   https://docs.pydantic.dev/latest/api/types/#pydantic.types.StringConstraints



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