slackapi / bolt-python

A framework to build Slack apps using Python
https://slack.dev/bolt-python/
MIT License
1.05k stars 245 forks source link

Static Select have a random initial value on iOS Slack App slack bolt python #1171

Open Artpel1805 opened 4 days ago

Artpel1805 commented 4 days ago

Hi everyone ! :)

I'm new to Slack app development. I am currently using Slack Bolt SDK for python.I have created a simple static select with 5 options :

class SectionStaticSelect(SectionBlock):
    def __init__(self):

        options_list : List[Option] = []
        for i in range(5):
            options_list.append(
                Option( 
                        value=f"select_option_{i}",
                        text= f"option{i}"
                    )
            )

        super().__init__(
            text=TextObject(
                type="mrkdwn",
                text="section"
            accessory=StaticSelectElement(
                action_id="select_option",
                options=options_list,
                placeholder="choose an option"
            ),
        )

This static select trigger my HomePage().push() function that simply trigger a new home page to the user client. Here is the class HomePage :

class HomePage:
    def __init__(self, *, client: WebClient, user_id: str):
        self.client = client
        self.user_id = user_id

    def push(self, view: View) -> SlackResponse:
        return self.client.views_publish(user_id=self.user_id, view=MainScreen())
class MainScreen(View):
    def __init__(
        self,
    ):
        blocks = [
           SectionStaticSelect()
        ]

        super().__init__(type="home", callback_id="home_view", blocks=blocks)

On desktop the app have the perfect expected behavior but on iOS, even if i haven't inputed any initial_option , the StaticSelect Slack Bolt element seems to take a random initial_value.

The slack_bolt version

slack_bolt 1.19.1 slack_sdk 3.31.0

Python runtime version

Python 3.12.1

OS info

ProductName: macOS ProductVersion: 14.2 BuildVersion: 23C64 Darwin Kernel Version 23.2.0: Wed Nov 15 21:59:33 PST 2023; root:xnu-10002.61.3~2/RELEASE_ARM64_T8112

iOS Version

Tested on Iphone 13 Pro Max 17.5.1 Slack App version 24.08.40 (443050)

Steps to reproduce:

  1. Experience the bug with SlackRequestHandler() for FastAPI
hello-ashleyintech commented 4 days ago

Hi, @Artpel1805! Thanks for submitting. Going to see if I can repro this - at initial read, it seems like this might be a device-related issue, so we may need to end up forwarding it to another channel if it is determined to be that.

Also while I try to repro, quick follow up q - for the initial_value that ends up surfacing on iOS, are you noticing any patterns? Is it just pulling a random value from the list? Is it pulling in a certain order?

Artpel1805 commented 4 days ago

Hello @hello-ashleyintech thanks for quick response and your advices ! I think i have figure out what is happening.

The first time i visit a view everything works well. But when i visit a second time the view - the initial value is the value of the Option i have choosen when i was on this View.

For example : I'm on View 1 for the first time (No initial Option), I visit View 4 (No initial Option), and go back to view 1 then Static Select indicates Option 4. And if i go to View 4 Static Select indicates Option 1

So it's seems i'm only retrieving a previous or a cached View instead of pushing a new one.