From 6add6455977c72ca0aefb489a29fd63b6628720a Mon Sep 17 00:00:00 2001 From: Reinier van der Leer Date: Wed, 24 Apr 2024 18:57:50 +0200 Subject: fix(agent): Expand failure check in `json_loads(..)` Not only check if the resulting object is `demjson3.undefined`, but also `demjson3.syntax_error`. --- autogpts/autogpt/autogpt/core/utils/json_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autogpts/autogpt/autogpt/core/utils/json_utils.py b/autogpts/autogpt/autogpt/core/utils/json_utils.py index 0374a85c1..45650427d 100644 --- a/autogpts/autogpt/autogpt/core/utils/json_utils.py +++ b/autogpts/autogpt/autogpt/core/utils/json_utils.py @@ -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) ) - if json_result.object is demjson3.undefined: + if json_result.object in (demjson3.syntax_error, demjson3.undefined): raise ValueError( f"Failed to parse JSON string: {json_str}", *json_result.errors ) -- cgit v1.2.3