[BugFix] Fix the multiple items check (#6294)

* check for multiple items when no info

* check for , and ; only if it's a str

---------

Co-authored-by: hjoaquim <h.joaquim@campus.fct.unl.pt>
This commit is contained in:
Henrique Joaquim
2024-04-09 11:15:18 +01:00
committed by GitHub
parent 153723d465
commit 8fed63e4c8
2 changed files with 12 additions and 1 deletions

View File

@@ -42,5 +42,16 @@ def filter_inputs(
kwargs[p][field] = new
break
else:
provider = kwargs.get("provider_choices", {}).get("provider")
for param_category in ("standard_params", "extra_params"):
if param_category in kwargs:
for field, value in kwargs[param_category].items():
if isinstance(value, list):
kwargs[param_category][field] = ",".join(map(str, value))
check_single_item(
kwargs[param_category][field],
f"{field} -> multiple items not allowed for '{provider}'",
)
return kwargs

View File

@@ -166,6 +166,6 @@ def check_single_item(
value: Optional[str], message: Optional[str] = None
) -> Optional[str]:
"""Check that string contains a single item."""
if value and ("," in value or ";" in value):
if value and isinstance(value, str) and ("," in value or ";" in value):
raise OpenBBError(message if message else "multiple items not allowed")
return value