From 8fed63e4c82613b5bc4c1da8b9b3c7c36c2bdfc0 Mon Sep 17 00:00:00 2001 From: Henrique Joaquim Date: Tue, 9 Apr 2024 11:15:18 +0100 Subject: [PATCH] [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 --- .../core/openbb_core/app/static/utils/filters.py | 11 +++++++++++ openbb_platform/core/openbb_core/app/utils.py | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/openbb_platform/core/openbb_core/app/static/utils/filters.py b/openbb_platform/core/openbb_core/app/static/utils/filters.py index 32a92138586..b2262a1e8c8 100644 --- a/openbb_platform/core/openbb_core/app/static/utils/filters.py +++ b/openbb_platform/core/openbb_core/app/static/utils/filters.py @@ -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 diff --git a/openbb_platform/core/openbb_core/app/utils.py b/openbb_platform/core/openbb_core/app/utils.py index f7c6c1ca7dc..452300c4334 100644 --- a/openbb_platform/core/openbb_core/app/utils.py +++ b/openbb_platform/core/openbb_core/app/utils.py @@ -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