diff --git a/slack_sdk/web/async_client.py b/slack_sdk/web/async_client.py index 46b95aa8b..27a1db1fd 100644 --- a/slack_sdk/web/async_client.py +++ b/slack_sdk/web/async_client.py @@ -2573,6 +2573,8 @@ async def apps_icon_set( file: File contents via `multipart/form-data` url: URL of a publicly hosted image """ + if file is None and url is None: + raise e.SlackRequestError("Either file or url must be provided.") kwargs.update({"app_id": app_id, "url": url}) if file is not None: return await self.api_call("apps.icon.set", files={"file": file}, data=kwargs) diff --git a/slack_sdk/web/client.py b/slack_sdk/web/client.py index 923bce351..9875dbe2d 100644 --- a/slack_sdk/web/client.py +++ b/slack_sdk/web/client.py @@ -2563,6 +2563,8 @@ def apps_icon_set( file: File contents via `multipart/form-data` url: URL of a publicly hosted image """ + if file is None and url is None: + raise e.SlackRequestError("Either file or url must be provided.") kwargs.update({"app_id": app_id, "url": url}) if file is not None: return self.api_call("apps.icon.set", files={"file": file}, data=kwargs) diff --git a/slack_sdk/web/legacy_client.py b/slack_sdk/web/legacy_client.py index 7e7d46e17..430fe8a8e 100644 --- a/slack_sdk/web/legacy_client.py +++ b/slack_sdk/web/legacy_client.py @@ -2574,6 +2574,8 @@ def apps_icon_set( file: File contents via `multipart/form-data` url: URL of a publicly hosted image """ + if file is None and url is None: + raise e.SlackRequestError("Either file or url must be provided.") kwargs.update({"app_id": app_id, "url": url}) if file is not None: return self.api_call("apps.icon.set", files={"file": file}, data=kwargs) diff --git a/tests/slack_sdk/web/test_web_client.py b/tests/slack_sdk/web/test_web_client.py index 498e4a205..5a8a405ed 100644 --- a/tests/slack_sdk/web/test_web_client.py +++ b/tests/slack_sdk/web/test_web_client.py @@ -78,6 +78,10 @@ def test_json_can_only_be_sent_with_post_requests(self): with self.assertRaises(err.SlackRequestError): self.client.api_call("fake.method", http_verb="GET", json={}) + def test_apps_icon_set_requires_file_or_url(self): + with self.assertRaises(err.SlackRequestError): + self.client.apps_icon_set(app_id="A111") + def test_slack_api_error_is_raised_on_unsuccessful_responses(self): self.client.token = "xoxb-api_test_false" with self.assertRaises(err.SlackApiError): diff --git a/tests/slack_sdk_async/web/test_async_web_client.py b/tests/slack_sdk_async/web/test_async_web_client.py index c4f345093..cc6f93f0a 100644 --- a/tests/slack_sdk_async/web/test_async_web_client.py +++ b/tests/slack_sdk_async/web/test_async_web_client.py @@ -52,6 +52,11 @@ async def test_json_can_only_be_sent_with_post_requests(self): with self.assertRaises(err.SlackRequestError): await self.client.api_call("fake.method", http_verb="GET", json={}) + @async_test + async def test_apps_icon_set_requires_file_or_url(self): + with self.assertRaises(err.SlackRequestError): + await self.client.apps_icon_set(app_id="A111") + @async_test async def test_slack_api_error_is_raised_on_unsuccessful_responses(self): self.client.token = "xoxb-api_test_false"