From c7911c7130f493695faec0fbb25cff89823d7f2b Mon Sep 17 00:00:00 2001 From: -LAN- Date: Tue, 31 Dec 2024 17:03:07 +0800 Subject: [PATCH] fix: improve JSON parsing error handling in Executor class (#12265) Signed-off-by: -LAN- --- api/core/workflow/nodes/http_request/executor.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/api/core/workflow/nodes/http_request/executor.py b/api/core/workflow/nodes/http_request/executor.py index fadd142e35..11842d58b1 100644 --- a/api/core/workflow/nodes/http_request/executor.py +++ b/api/core/workflow/nodes/http_request/executor.py @@ -158,7 +158,10 @@ class Executor: if len(data) != 1: raise RequestBodyError("json body type should have exactly one item") json_string = self.variable_pool.convert_template(data[0].value).text - json_object = json.loads(json_string, strict=False) + try: + json_object = json.loads(json_string, strict=False) + except json.JSONDecodeError as e: + raise RequestBodyError(f"Failed to parse JSON: {json_string}") from e self.json = json_object # self.json = self._parse_object_contains_variables(json_object) case "binary":