diff options
author | Henrique Joaquim <henriquecjoaquim@gmail.com> | 2024-04-09 11:15:18 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-09 10:15:18 +0000 |
commit | 8fed63e4c82613b5bc4c1da8b9b3c7c36c2bdfc0 (patch) | |
tree | ce7cb361f6e8f7ec013400c3a9055c703dcb7bc4 | |
parent | 153723d465144905a0b8b403718ba5144a40f493 (diff) |
[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>
-rw-r--r-- | openbb_platform/core/openbb_core/app/static/utils/filters.py | 11 | ||||
-rw-r--r-- | openbb_platform/core/openbb_core/app/utils.py | 2 |
2 files changed, 12 insertions, 1 deletions
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 |