Skip to content

Why Does MultiSelect and StaticSelect Options Default to Incompatible Text Type #1056

@weallwegot

Description

@weallwegot

(Describe your issue and goal here)

Hi - im not sure if this is a bug or just unexpected behavior. im working with the blocks library in the python SDK and the basic_components.Option objects that are used in RadioButtonElement, StaticSelectElement, etc require "plain_text" types for their text fields, but if you use the basic_components.Option(text="some random text", value="True") the text defaults to mrkdwn, which will then give an error about not matching schemas.

Reproducible in:

here is the json dump of what gets generated by the block kit sdk

>>> json.dumps(basic_components.Option(text="text0",value="text0").to_dict())
>>> {"text": {"text": "text0", "type": "mrkdwn"}, "value": "text0"}
but the default to mrkdwn for option text types does not work in certain block elements..
this is an example of a block that does not render bc the text types default to markdown

{
	"blocks": [
		{
			"type": "input",
			"element": {
				"type": "multi_static_select",
				"options": [
					{
						"text": {
							"text": "text0",
							"type": "mrkdwn"
						},
						"value": "text-0"
					},
					{
						"text": {
							"text": "text1",
							"type": "mrkdwn"
						},
						"value": "text-1"
					},
					{
						"text": {
							"text": "text2",
							"type": "mrkdwn"
						},
						"value": "text-2"
					}
				]
			},
			"label": {
				"emoji": true,
				"text": "Label 2 With Markdown Text in Input Block",
				"type": "plain_text"
			}
		}
	]
}

and then an example of an identical block with the only difference being the text type is now plain_text

{"blocks":[
		{
			"type": "input",
			"element": {
				"type": "multi_static_select",
				"placeholder": {
					"type": "plain_text",
					"text": "Select an item",
					"emoji": true
				},
				"options": [
					{
						"text": {
							"type": "plain_text",
							"text": "*text0*",
							"emoji": true
						},
						"value": "value-0"
					},
					{
						"text": {
							"type": "plain_text",
							"text": "*text1*",
							"emoji": true
						},
						"value": "value-1"
					},
					{
						"text": {
							"type": "plain_text",
							"text": "*text2*",
							"emoji": true
						},
						"value": "value-2"
					}
				],
				"action_id": "static_select-action"
			},
			"label": {
				"type": "plain_text",
				"text": "Label 1 With Plain Text in Input Block",
				"emoji": true
			}
		}]}

I'm curious why the default text_type for Option is mrkdwn if it is incompatible with some of the element types? i see this point in the code, but im curious if maybe theres a way to give an error message that lets developers know when this will cause issues with other interactive components.

The slack_bolt version

slack-bolt==1.6.1
slack-sdk==3.7.0

Python runtime version

Python 3.6.8 :: Anaconda, Inc.

OS info

ProductName:	Mac OS X
ProductVersion:	10.15.7

Steps to reproduce:

import json
from slack_sdk.models.blocks import block_elements, blocks, basic_components

json.dumps(basic_components.Option(text="text0",value="text0").to_dict())

>>> {"text": {"text": "text0", "type": "mrkdwn"}, "value": "text0"}

Expected result:

i expect that in using the basic_components.Option with a StaticSelectElement or StaticMultiSelectElement the resulting block would be defined and render appropriately.
within the Slack Bot Kit Builder

or expect an error message that tells you about the plain_text type requirement for some of the block_elements and which elements they are. from what ive seen its StaticSelectElement StaticMultiSelectElement

Actual result:

using the default types for text within a StaticSelectElement or StaticMultiSelectElement results in a schema violation:

Screen Shot 2021-07-07 at 10 47 28 PM

Requirements

Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions