Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1053 by changing request body format to params #1054

Merged
merged 1 commit into from Jul 1, 2021

Conversation

seratch
Copy link
Member

@seratch seratch commented Jul 1, 2021

Summary

This pull request fixes #1053 by eliminating the potential issues with a single comma-separated-value format data for a sequence type parameter (e.g., channel_ids, user_ids, etc.) in JSON request body.

As far as I did tests with the mentioned endpoint, a single CSV format string value works even in the JSON request body. That being said, it should be much safer to switch the content-type from application/json to application/x-www-form-urlencoded in the long run. It is a proven way in the Java SDK and some others.

We may want to eventually switch all the API methods to application/x-www-form-urlencoded for simplicity but it's out of this pull request's scope.

Category (place an x in each of the [ ])

  • slack_sdk.web.WebClient (sync/async) (Web API client)
  • slack_sdk.webhook.WebhookClient (sync/async) (Incoming Webhook, response_url sender)
  • slack_sdk.socket_mode (Socket Mode client)
  • slack_sdk.signature (Request Signature Verifier)
  • slack_sdk.oauth (OAuth Flow Utilities)
  • slack_sdk.models (UI component builders)
  • slack_sdk.scim (SCIM API client)
  • slack_sdk.audit_logs (Audit Logs API client)
  • slack_sdk.rtm_v2 (RTM client)
  • /docs-src (Documents, have you run ./docs.sh?)
  • /docs-src-v2 (Documents, have you run ./docs-v2.sh?)
  • /tutorial (PythOnBoardingBot tutorial)
  • tests/integration_tests (Automated tests for this library)

Requirements (place an x in each [ ])

  • I've read and understood the Contributing Guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've run python3 -m venv .venv && source .venv/bin/activate && ./scripts/run_validation.sh after making the changes.

@seratch seratch added enhancement M-T: A feature request for new functionality web-client Version: 3x labels Jul 1, 2021
@seratch seratch added this to the 3.8.0 milestone Jul 1, 2021
@@ -26,7 +26,7 @@ async def setUp(self):
].replace("#", "")
client = AsyncWebClient(token=token)
self.channel_id = None
async for resp in await client.conversations_list(limit=10):
async for resp in await client.conversations_list(limit=1000):
Copy link
Member Author

Choose a reason for hiding this comment

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

To avoid ratelimited errors with my test workspace (it has a very large number of channels)

@@ -621,7 +621,7 @@ async def admin_users_session_getSettings(
kwargs.update({"user_ids": ",".join(user_ids)})
Copy link
Member Author

Choose a reason for hiding this comment

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

This code currently works but the server-side may stop accepting this format in the future. That's the reason why we want to make the changes in this PR.

@codecov
Copy link

codecov bot commented Jul 1, 2021

Codecov Report

Merging #1054 (b834de2) into main (3422a23) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1054   +/-   ##
=======================================
  Coverage   84.36%   84.36%           
=======================================
  Files          95       95           
  Lines        8937     8937           
=======================================
  Hits         7540     7540           
  Misses       1397     1397           
Impacted Files Coverage Δ
slack_sdk/web/async_client.py 93.93% <100.00%> (ø)
slack_sdk/web/client.py 95.38% <100.00%> (ø)
slack_sdk/web/legacy_client.py 95.25% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3422a23...b834de2. Read the comment docs.

@seratch
Copy link
Member Author

seratch commented Jul 1, 2021

Thanks for your prompt review!

@seratch seratch merged commit 44e5554 into slackapi:main Jul 1, 2021
@seratch seratch deleted the issue-1053-sequence-value-in-json branch July 1, 2021 21:53
@seratch seratch mentioned this pull request Aug 12, 2021
16 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement M-T: A feature request for new functionality Version: 3x web-client
Projects
None yet
Development

Successfully merging this pull request may close these issues.

conversations_invite() fails with "error: no_user"
2 participants