Skip to content

"unpack requires a buffer of 2 bytes" error when we have many options / option groups #1230

@adamtheturtle

Description

@adamtheturtle

"unpack requires a buffer of 2 bytes" error when we have many options / option groups

Reproducible in:

The slack_bolt version

slack-bolt==1.14.0
slack-sdk==3.17.1

Python runtime version

Python 3.9.13

OS info

ProductName:    macOS
ProductVersion: 12.4
BuildVersion:   21F79
Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:29 PDT 2022; root:xnu-8020.121.3~
4/RELEASE_ARM64_T8101

Steps to reproduce:

(Share the commands to run, source code, and project settings (e.g., setup.py))

  1. Create an environment with slack-bolt, no other dependencies

  2. Create a Slack application which takes the slash command /command, and runs with Socket mode enabled

  3. Serve the following application:

import os
from slack_bolt import App
from slack_bolt.adapter.socket_mode import SocketModeHandler
from typing import Final

from slack_sdk.models.blocks.basic_components import PlainTextObject
from slack_sdk.models.blocks.block_elements import (
    StaticSelectElement,
    OptionGroup,
    Option,
)

from slack_sdk.models.blocks.blocks import ActionsBlock
from slack_sdk.models.views import View


os.environ[
    "SLACK_APP_TOKEN"
] = "XXX FILL THIS IN"
bot_token = "XXX FILL THIS IN"

app = App(token=bot_token)

_VIEW: Final[View] = View(
    type="modal",
    title=PlainTextObject(text="My title"),
    submit=PlainTextObject(text="Submit"),
    close=PlainTextObject(text="Cancel"),
    blocks=[
        ActionsBlock(
            block_id="block",
            label=PlainTextObject(text="Some label"),
            elements=[
                StaticSelectElement(
                    action_id="a",
                    option_groups=[
                        OptionGroup(
                            label="Label" * 8,
                            options=[
                                Option(value="a" * 75, text="b" * 75) for i in range(30)
                            ],
                        )
                        for i in range(10)
                    ],
                ),
            ],
        ),
    ],
)


@app.command("/command")
def handle_some_action(ack, body, client):
    ack()
    client.views_open(
        trigger_id=body["trigger_id"],
        view=_VIEW,
    )


if __name__ == "__main__":
    handler = SocketModeHandler(app=app)
    handler.start()
  1. Type /command in Slack to bring up the application

  2. Choose an option in the dropdown, then choose another, then choose another

Expected result:

No error in the application logs.
No error in the form.

Actual result:

Logs like this are shown every time:

⚡️ Bolt app is running!
on_error invoked (session id: 050bfaac-d760-4721-824e-5e9a7032eb23, error: error, message: unpack requires a buffer of 2 bytes)
on_error invoked (session id: 050bfaac-d760-4721-824e-5e9a7032eb23, error: error, message: unpack requires a buffer of 2 bytes)
Received an unsupported data frame (session id: 050bfaac-d760-4721-824e-5e9a7032eb23, opcode: binary, payload: b'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb","emoji":true},"value":"aaaaaaaaaaaaaaaaaaaaaaaa')
Received an unsupported data frame (session id: 050bfaac-d760-4721-824e-5e9a7032eb23, opcode: binary, payload: b'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb","emoji":true},"value":"aaaaaaaa')

After a spinner spins, we see the exclamation mark item on our form:

slack_bolt_error

Metadata

Metadata

Assignees

Labels

bugM-T: A confirmed bug report. Issues are confirmed when the reproduction steps are documentedsocket-mode

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions