🔧 fix(types.py): add exception handling when evaluating field_value using ast.literal_eval to prevent potential errors

🔀 chore(types.py): import ast and contextlib modules for future use
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-08-03 15:28:15 -03:00
commit dc8097ebd7

View file

@ -1,3 +1,5 @@
import ast
import contextlib
from typing import Any
from langflow.interface.agents.base import agent_creator
from langflow.interface.chains.base import chain_creator
@ -250,6 +252,8 @@ def get_field_properties(extra_field):
if not field_required:
field_type = extract_type_from_optional(field_type)
with contextlib.suppress(Exception):
field_value = ast.literal_eval(field_value)
return field_name, field_type, field_value, field_required