diff --git a/api/core/helper/code_executor/template_transformer.py b/api/core/helper/code_executor/template_transformer.py index b7a07b21e1d784..cf422fd023e01e 100644 --- a/api/core/helper/code_executor/template_transformer.py +++ b/api/core/helper/code_executor/template_transformer.py @@ -33,13 +33,16 @@ def extract_result_str_from_response(cls, response: str) -> str: return result @classmethod - def transform_response(cls, response: str) -> dict: + def transform_response(cls, response: str): """ Transform response to dict :param response: response :return: """ - return json.loads(cls.extract_result_str_from_response(response)) + result = json.loads(cls.extract_result_str_from_response(response)) + if not isinstance(result, dict): + raise ValueError("Result must be a dict") + return result @classmethod @abstractmethod