Skip to content
Merged
Prev Previous commit
Next Next commit
Patch fixes and better test coverage
  • Loading branch information
WilliamBergamin committed Mar 17, 2026
commit 3e4946168c6b528e99ce203a69dda6173670701d
1 change: 1 addition & 0 deletions slack_bolt/kwargs_injection/async_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def build_async_required_kwargs(
"set_suggested_prompts": request.context.set_suggested_prompts,
"get_thread_context": request.context.get_thread_context,
"save_thread_context": request.context.save_thread_context,
"say_stream": request.context.say_stream,
# middleware
"next": next_func,
"next_": next_func, # for the middleware using Python's built-in `next()` function
Expand Down
1 change: 1 addition & 0 deletions slack_bolt/kwargs_injection/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def build_required_kwargs(
"set_title": request.context.set_title,
"set_suggested_prompts": request.context.set_suggested_prompts,
"save_thread_context": request.context.save_thread_context,
"say_stream": request.context.say_stream,
# middleware
"next": next_func,
"next_": next_func, # for the middleware using Python's built-in `next()` function
Expand Down
21 changes: 21 additions & 0 deletions tests/scenario_tests/test_events_say_stream.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import json
import time
from urllib.parse import quote

import pytest
from slack_sdk.web import WebClient
Expand All @@ -17,6 +19,7 @@
user_message_event_body as threaded_user_message_event_body,
)
from tests.scenario_tests.test_message_bot import bot_message_event_payload, user_message_event_payload
from tests.scenario_tests.test_view_submission import body as view_submission_body
from tests.utils import remove_os_env_temporarily, restore_os_env


Expand Down Expand Up @@ -169,3 +172,21 @@ def handle_user_message(say_stream: SayStream):
response = app.dispatch(request)
assert response.status == 200
assert_target_called(called)

def test_say_stream_is_none_for_view_submission(self):
app = App(client=self.web_client, request_verification_enabled=False)
called = {"value": False}

@app.view("view-id")
def handle_view(ack, say_stream, context: BoltContext):
ack()
assert say_stream is None
assert context.say_stream is None
Comment on lines +198 to +199

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🌟 praise: This is a pleasant assertion to have for application code guards too I think!

called["value"] = True

request = BoltRequest(
body=f"payload={quote(json.dumps(view_submission_body))}",
)
response = app.dispatch(request)
assert response.status == 200
assert_target_called(called)
22 changes: 22 additions & 0 deletions tests/scenario_tests_async/test_events_say_stream.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import asyncio
import json
import time
from urllib.parse import quote

import pytest
from slack_sdk.web.async_client import AsyncWebClient
Expand All @@ -18,6 +20,7 @@
from tests.scenario_tests_async.test_events_assistant import user_message_event_body as threaded_user_message_event_body
from tests.scenario_tests_async.test_events_assistant import thread_started_event_body, user_message_event_body
from tests.scenario_tests_async.test_message_bot import bot_message_event_payload, user_message_event_payload
from tests.scenario_tests_async.test_view_submission import body as view_submission_body
from tests.utils import remove_os_env_temporarily, restore_os_env


Expand Down Expand Up @@ -179,3 +182,22 @@ async def handle_user_message(say_stream: AsyncSayStream, context: AsyncBoltCont
response = await app.async_dispatch(request)
assert response.status == 200
await assert_target_called(called)

@pytest.mark.asyncio
async def test_say_stream_is_none_for_view_submission(self):
app = AsyncApp(client=self.web_client, request_verification_enabled=False)
called = {"value": False}

@app.view("view-id")
async def handle_view(ack, say_stream, context: AsyncBoltContext):
await ack()
assert say_stream is None
assert context.say_stream is None
called["value"] = True

request = AsyncBoltRequest(
body=f"payload={quote(json.dumps(view_submission_body))}",
)
response = await app.async_dispatch(request)
assert response.status == 200
await assert_target_called(called)