From f004e460a00249bc1ee14a61b1d85af0b948c549 Mon Sep 17 00:00:00 2001 From: David Whittaker Date: Fri, 16 May 2025 14:35:30 -0700 Subject: [PATCH 1/2] fix(slack): PlainOption requires string values --- src/dispatch/plugins/dispatch_slack/fields.py | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/src/dispatch/plugins/dispatch_slack/fields.py b/src/dispatch/plugins/dispatch_slack/fields.py index 0cee3bd609ab..04356562cb7b 100644 --- a/src/dispatch/plugins/dispatch_slack/fields.py +++ b/src/dispatch/plugins/dispatch_slack/fields.py @@ -262,11 +262,27 @@ def static_select_block( **kwargs, ): """Builds a static select block.""" + # Ensure all values in options are strings + processed_options = [] + if options: + for x in options: + option_dict = {k: str(v) if k == "value" else v for k, v in x.items()} + processed_options.append(option_dict) + + # Ensure value in initial_option is a string + processed_initial_option = None + if initial_option: + processed_initial_option = { + k: str(v) if k == "value" else v for k, v in initial_option.items() + } + return Input( element=StaticSelect( placeholder=placeholder, - options=[PlainOption(**x) for x in options] if options else None, - initial_option=PlainOption(**initial_option) if initial_option else None, + options=[PlainOption(**x) for x in processed_options] if processed_options else None, + initial_option=( + PlainOption(**processed_initial_option) if processed_initial_option else None + ), action_id=action_id, ), block_id=block_id, @@ -284,10 +300,17 @@ def multi_select_block( **kwargs, ): """Builds a multi select block.""" + # Ensure all values in options are strings + processed_options = [] + if options: + for x in options: + option_dict = {k: str(v) if k == "value" else v for k, v in x.items()} + processed_options.append(option_dict) + return Input( element=MultiStaticSelect( placeholder=placeholder, - options=[PlainOption(**x) for x in options] if options else None, + options=[PlainOption(**x) for x in processed_options] if processed_options else None, action_id=action_id, ), block_id=block_id, From 1e3056e8f44d867c168319a0e2251b517dfa1233 Mon Sep 17 00:00:00 2001 From: David Whittaker Date: Fri, 16 May 2025 14:51:38 -0700 Subject: [PATCH 2/2] Correcting type signatures --- src/dispatch/plugins/dispatch_slack/fields.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/dispatch/plugins/dispatch_slack/fields.py b/src/dispatch/plugins/dispatch_slack/fields.py index 04356562cb7b..bae73e41a1b2 100644 --- a/src/dispatch/plugins/dispatch_slack/fields.py +++ b/src/dispatch/plugins/dispatch_slack/fields.py @@ -253,11 +253,11 @@ def datetime_picker_block( def static_select_block( - options: list[str], + options: list[dict[str, str]], placeholder: str, action_id: str = None, block_id: str = None, - initial_option: dict = None, + initial_option: dict[str, str] = None, label: str = None, **kwargs, ): @@ -292,7 +292,7 @@ def static_select_block( def multi_select_block( - options: list[str], + options: list[dict[str, str]], placeholder: str, action_id: str = None, block_id: str = None,