Skip to content

Commit b11b323

Browse files
zimegmwbrooksClaude
authored
fix(web): raise an error when apps_icon_set gets neither file nor url (#2060)
Co-authored-by: Michael Brooks <21328+mwbrooks@users.noreply.github.com> Co-authored-by: Claude <svc-devxp-claude@slack-corp.com>
1 parent e1811b7 commit b11b323

5 files changed

Lines changed: 15 additions & 0 deletions

File tree

‎slack_sdk/web/async_client.py‎

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎slack_sdk/web/client.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2563,6 +2563,8 @@ def apps_icon_set(
25632563
file: File contents via `multipart/form-data`
25642564
url: URL of a publicly hosted image
25652565
"""
2566+
if file is None and url is None:
2567+
raise e.SlackRequestError("Either file or url must be provided.")
25662568
kwargs.update({"app_id": app_id, "url": url})
25672569
if file is not None:
25682570
return self.api_call("apps.icon.set", files={"file": file}, data=kwargs)

‎slack_sdk/web/legacy_client.py‎

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎tests/slack_sdk/web/test_web_client.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ def test_json_can_only_be_sent_with_post_requests(self):
7878
with self.assertRaises(err.SlackRequestError):
7979
self.client.api_call("fake.method", http_verb="GET", json={})
8080

81+
def test_apps_icon_set_requires_file_or_url(self):
82+
with self.assertRaises(err.SlackRequestError):
83+
self.client.apps_icon_set(app_id="A111")
84+
8185
def test_slack_api_error_is_raised_on_unsuccessful_responses(self):
8286
self.client.token = "xoxb-api_test_false"
8387
with self.assertRaises(err.SlackApiError):

‎tests/slack_sdk_async/web/test_async_web_client.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ async def test_json_can_only_be_sent_with_post_requests(self):
5252
with self.assertRaises(err.SlackRequestError):
5353
await self.client.api_call("fake.method", http_verb="GET", json={})
5454

55+
@async_test
56+
async def test_apps_icon_set_requires_file_or_url(self):
57+
with self.assertRaises(err.SlackRequestError):
58+
await self.client.apps_icon_set(app_id="A111")
59+
5560
@async_test
5661
async def test_slack_api_error_is_raised_on_unsuccessful_responses(self):
5762
self.client.token = "xoxb-api_test_false"

0 commit comments

Comments
 (0)