@@ -81,25 +81,36 @@ def handle(self, parsed_route: Route, request: HTTPRequest) -> HTTPResponse:
8181 HTTPResponse: The HTTP response to send to the client
8282 """
8383
84- def _parse_json_body (
85- self , request : HTTPRequest , required : bool = True
86- ) -> dict [str , Any ]:
84+ def _parse_json_body (self , request : HTTPRequest ) -> dict [str , Any ]:
8785 """Parse JSON body from HTTP request with validation.
8886
8987 Args:
9088 request: The HTTP request containing the JSON body
91- required: Whether the request body is required
9289
9390 Returns:
94- dict: The parsed JSON data, or empty dict if not required and missing
91+ dict: The parsed JSON data
9592
9693 Raises:
97- InvalidParameterValueException: If the request body is required but empty or invalid JSON
94+ InvalidParameterValueException: If the request body is empty
95+ """
96+ if not request .body :
97+ msg = "Request body is required"
98+ 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
98112 """
99113 if not request .body :
100- if required :
101- msg = "Request body is required"
102- raise InvalidParameterValueException (msg )
103114 return {}
104115
105116 # Handle both dict and bytes body types
@@ -695,7 +706,7 @@ def handle(self, parsed_route: Route, request: HTTPRequest) -> HTTPResponse:
695706 callback_route = cast (CallbackFailureRoute , parsed_route )
696707 callback_id : str = callback_route .callback_id
697708
698- body_data : dict [str , Any ] = self ._parse_json_body (request , required = False )
709+ body_data : dict [str , Any ] = self ._parse_json_body_optional (request )
699710 callback_request : SendDurableExecutionCallbackFailureRequest = (
700711 SendDurableExecutionCallbackFailureRequest .from_dict (
701712 body_data , callback_id
0 commit comments