mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2025-12-17 05:54:26 +01:00
fix(agent): Expand failure check in json_loads(..)
Not only check if the resulting object is `demjson3.undefined`, but also `demjson3.syntax_error`.
This commit is contained in:
@@ -39,7 +39,7 @@ def json_loads(json_str: str) -> Any:
|
|||||||
"JSON parse errors:\n" + "\n".join(str(e) for e in json_result.errors)
|
"JSON parse errors:\n" + "\n".join(str(e) for e in json_result.errors)
|
||||||
)
|
)
|
||||||
|
|
||||||
if json_result.object is demjson3.undefined:
|
if json_result.object in (demjson3.syntax_error, demjson3.undefined):
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
f"Failed to parse JSON string: {json_str}", *json_result.errors
|
f"Failed to parse JSON string: {json_str}", *json_result.errors
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user