Slack supports StaticSelect menus with grouped options, so that you can separate the options into related sets. It can also support specifying an initially selected option. Slack lets you do both at the same time. BlockKit v1 let you do both at the same time. BlockKit v2 fails when you try to do this while validating the option selections, raising the error:
blockkit.core.ComponentValidationError: Component 'StaticSelect': 'initial_option' has items that aren't present in the 'option_groups'
The problem seems to stem from the use of Within validators attached to the StaticSelect class (the MultiStaticSelect has the same issue). The value for the initial_option is a single option (for initial_options for the multi-select it's a flat list of options) and you are comparing it to a list of groups, not a list of options.
The fix should be in the Within validator. When the target field contains OptionGroup objects, it should collect the options from within them and check if the initial value is a subset of the flattened set of values within the groups, rather than comparing against the groups themselves (which will always fail).
blockkit_bug_demo.py
Slack supports StaticSelect menus with grouped options, so that you can separate the options into related sets. It can also support specifying an initially selected option. Slack lets you do both at the same time. BlockKit v1 let you do both at the same time. BlockKit v2 fails when you try to do this while validating the option selections, raising the error:
The problem seems to stem from the use of Within validators attached to the StaticSelect class (the MultiStaticSelect has the same issue). The value for the
initial_optionis a single option (forinitial_optionsfor the multi-select it's a flat list of options) and you are comparing it to a list of groups, not a list of options.The fix should be in the Within validator. When the target field contains OptionGroup objects, it should collect the options from within them and check if the initial value is a subset of the flattened set of values within the groups, rather than comparing against the groups themselves (which will always fail).
blockkit_bug_demo.py