🐛 fix(loading.py): handle invalid JSON strings in kwargs by removing the key from params

This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-08-02 15:54:57 -03:00
commit 5d75d46aef

View file

@ -60,7 +60,12 @@ def convert_kwargs(params):
kwargs_keys = [key for key in params.keys() if "kwargs" in key or "config" in key]
for key in kwargs_keys:
if isinstance(params[key], str):
params[key] = json.loads(params[key])
try:
params[key] = json.loads(params[key])
except json.JSONDecodeError:
# if the string is not a valid json string, we will
# remove the key from the params
params.pop(key, None)
return params