From e55f79af57091dbb95926f2ffa7e3cf9fbd58550 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 28 May 2026 03:11:19 +0000 Subject: [PATCH] fix(slack): use channel= kwarg for files_upload_v2 (closes #102) 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 TypeError on every upload. Adds a regression test pinning the kwarg name. https://claude.ai/code/session_01WArZSuq5JFJwM9ecwqthhX --- src/chat_sdk/adapters/slack/adapter.py | 2 +- tests/test_slack_api.py | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/chat_sdk/adapters/slack/adapter.py b/src/chat_sdk/adapters/slack/adapter.py index 918240a..4f78847 100644 --- a/src/chat_sdk/adapters/slack/adapter.py +++ b/src/chat_sdk/adapters/slack/adapter.py @@ -2682,7 +2682,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 diff --git a/tests/test_slack_api.py b/tests/test_slack_api.py index c5fc7ed..9794f2c 100644 --- a/tests/test_slack_api.py +++ b/tests/test_slack_api.py @@ -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."""