@@ -91,11 +91,27 @@ def _parse_json_body(self, request: HTTPRequest) -> dict[str, Any]:
9191 dict: The parsed JSON data
9292
9393 Raises:
94- InvalidParameterValueException: If the request body is empty or invalid JSON
94+ InvalidParameterValueException: If the request body is empty
9595 """
9696 if not request .body :
9797 msg = "Request body is required"
9898 raise InvalidParameterValueException (msg )
99+ return self ._parse_json_body_optional (request )
100+
101+ def _parse_json_body_optional (self , request : HTTPRequest ) -> dict [str , Any ]:
102+ """Parse JSON body from HTTP request with validation.
103+
104+ Args:
105+ request: The HTTP request containing the JSON body
106+
107+ Returns:
108+ dict: The parsed JSON data
109+
110+ Raises:
111+ InvalidParameterValueException: If the request body is invalid JSON
112+ """
113+ if not request .body :
114+ return {}
99115
100116 # Handle both dict and bytes body types
101117 if isinstance (request .body , dict ):
@@ -690,7 +706,7 @@ def handle(self, parsed_route: Route, request: HTTPRequest) -> HTTPResponse:
690706 callback_route = cast (CallbackFailureRoute , parsed_route )
691707 callback_id : str = callback_route .callback_id
692708
693- body_data : dict [str , Any ] = self ._parse_json_body (request )
709+ body_data : dict [str , Any ] = self ._parse_json_body_optional (request )
694710 callback_request : SendDurableExecutionCallbackFailureRequest = (
695711 SendDurableExecutionCallbackFailureRequest .from_dict (
696712 body_data , callback_id
@@ -734,10 +750,7 @@ def handle(self, parsed_route: Route, request: HTTPRequest) -> HTTPResponse:
734750 HTTPResponse: The HTTP response to send to the client
735751 """
736752 try :
737- # Parse request body for validation but heartbeat doesn't use the data
738- body_data : dict [str , Any ] = self ._parse_json_body (request )
739- SendDurableExecutionCallbackHeartbeatRequest .from_dict (body_data )
740-
753+ # Heartbeat requests don't have a body, only callback_id from URL
741754 callback_route = cast (CallbackHeartbeatRoute , parsed_route )
742755 callback_id : str = callback_route .callback_id
743756
0 commit comments