fix(agent): Expand failure check in `json_loads(..)`

Not only check if the resulting object is `demjson3.undefined`, but also `demjson3.syntax_error`.
release-autogpt-v0.5.x
Reinier van der Leer 2024-04-24 18:57:50 +02:00
parent a88d5fca86
commit d2260bec5a
No known key found for this signature in database
GPG Key ID: CDC1180FDAE06193
1 changed files with 1 additions and 1 deletions

View File

@ -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
)