Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SlackObjectFormationError: options attribute must have between 2 and 5 items whereas API allows a single option #1218

Closed
wilhelmklopp opened this issue May 25, 2022 · 2 comments · Fixed by #1219
Labels
bug M-T: A confirmed bug report. Issues are confirmed when the reproduction steps are documented Version: 3x web-client
Milestone

Comments

@wilhelmklopp
Copy link

Reproducible in:

The Slack SDK version

slack-sdk==3.16.1

Python runtime version

Python 3.10.3

OS info

ProductName: macOS
ProductVersion: 12.3.1
BuildVersion: 21E258
Darwin Kernel Version 21.4.0: Fri Mar 18 00:46:32 PDT 2022; root:xnu-8020.101.4~15/RELEASE_ARM64_T6000

Steps to reproduce:

        Message(
            text="placeholder",
            blocks=[
                SectionBlock(
                    text="placeholder",
                    accessory=OverflowMenuElement(
                        options=[Option(value="placeholder", text="placeholder")]
                    ),
                )
            ],
        ).to_dict()

^ This will fail with slack_sdk.errors.SlackObjectFormationError: options attribute must have between 2 and 5 item

It used to be that the API required a minimum of two option entries in the overflow menu, but for a number of years now it has permitted just a single one.

Expected result:

No error is thrown and the object is converted to a dict.

Block kit builder screenshot to confirm that the API allows a single option:
image

{
	"blocks": [
		{
			"type": "section",
			"text": {
				"type": "mrkdwn",
				"text": "This is a section block with an overflow menu with a single option."
			},
			"accessory": {
				"type": "overflow",
				"options": [
					{
						"text": {
							"type": "plain_text",
							"text": "A single option",
							"emoji": true
						}
					}
				]
			}
		}
	]
}

Actual result:

An error is thrown: slack_sdk.errors.SlackObjectFormationError: options attribute must have between 2 and 5 item

@misscoded misscoded added bug M-T: A confirmed bug report. Issues are confirmed when the reproduction steps are documented and removed untriaged labels May 25, 2022
@misscoded
Copy link
Contributor

Hi @wilhelmklopp 👋🏼 Thanks for raising this issue and for providing such thorough details. I've confirmed what you're seeing and verified that a single entry works as expected, despite documentation and the SDK indicating otherwise.

We'll get a fix out for this shortly!

@wilhelmklopp
Copy link
Author

wilhelmklopp commented May 26, 2022

Thank you! Appreciate the speedy turnaround :)

@seratch seratch modified the milestones: 3.16.3, 3.17.0 May 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug M-T: A confirmed bug report. Issues are confirmed when the reproduction steps are documented Version: 3x web-client
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants