Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/chat_sdk/adapters/slack/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4012,7 +4012,7 @@ async def _upload_files(
)

client = self._get_client()
kwargs: dict[str, Any] = {"channel_id": channel, "file_uploads": file_uploads}
kwargs: dict[str, Any] = {"channel": channel, "file_uploads": file_uploads}
if thread_ts:
kwargs["thread_ts"] = thread_ts

Expand Down
26 changes: 26 additions & 0 deletions tests/test_slack_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,32 @@ async def test_file_only_post_returns_file_id(self):
# chat_postMessage should not have been called
assert len(client.get_calls("chat_postMessage")) == chat_post_calls_before

@pytest.mark.asyncio
async def test_file_upload_uses_channel_kwarg_not_channel_id(self):
"""Regression: slack-sdk's files_upload_v2 takes ``channel=``, not ``channel_id=``.

Passing ``channel_id=`` collides with the kwarg slack-sdk adds internally
when it forwards to files_completeUploadExternal, raising a TypeError on
every upload. See issue #102.
"""
adapter, client, _ = await _init_adapter()
client.set_response("files_upload_v2", {"ok": True, "files": [{"files": [{"id": "F999"}]}]})

from chat_sdk.types import FileUpload, PostableMarkdown

msg = PostableMarkdown(
markdown="",
files=[FileUpload(data=b"hello", filename="test.txt")],
)
await adapter.post_message("slack:C789:1234567890.000000", msg)

upload_calls = client.get_calls("files_upload_v2")
assert len(upload_calls) == 1
kwargs = upload_calls[0]["kwargs"]
assert kwargs["channel"] == "C789"
assert "channel_id" not in kwargs
assert kwargs["thread_ts"] == "1234567890.000000"

@pytest.mark.asyncio
async def test_thread_reply(self):
"""postMessage to a thread should include thread_ts."""
Expand Down
Loading