Skip to content

Commit

Permalink
fix: validate response type in transform_response method
Browse files Browse the repository at this point in the history
Signed-off-by: -LAN- <[email protected]>
  • Loading branch information
laipz8200 committed Dec 21, 2024
1 parent 786cb68 commit 3dec254
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions api/core/helper/code_executor/template_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3dec254

Please sign in to comment.