bug: improve the slack url overwriting experience
(Filling out the following details about bugs will help us solve your issue sooner.)
Steps to reproduce:
(Share the commands to run, source code, and project settings (e.g., setup.py))
- Try setting up an app to point to a different slack url that does not include a trailing
/ -
app = App(token=os.environ.get("SLACK_BOT_TOKEN"), client=WebClient(os.environ.get("SLACK_BOT_TOKEN"), "https://example.slack.com/api")) - This will fail 🔴
- Add a trailing
/app = App(token=os.environ.get("SLACK_BOT_TOKEN"), client=WebClient(os.environ.get("SLACK_BOT_TOKEN"), "https://example.slack.com/api/")) - This will pass 🟢
Expected result:
app = App(token=os.environ.get("SLACK_BOT_TOKEN"), client=WebClient(os.environ.get("SLACK_BOT_TOKEN"), "https://example.slack.com/api"))
Should provide an informative error or format the slack URL to work
Requirements
Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.
@WilliamBergamin This idea should be helpful in some situations, but it sounds like an improvement on the slack-sdk side. What do you think?
I moved the issue over to python-slack-sdk
Hi, can I work on this issue?
Hi everyone,
I've made a change to address an issue in the base URL handling in the SDK. Specifically:
-
Changes in
base_client.py:- Updated the code to ensure the
base_urlends with a/if it's not already present. - See the relevant change here: base_client.py.
- Updated the code to ensure the
-
Added Tests in
test_web_client.py:- Added test cases to validate the updated
base_urlbehavior. - You can find the new tests here: test_web_client.py.
- Added test cases to validate the updated
During testing, I encountered an issue with the file test_interactions_aiohttp.py. For some reason, this test seems to hang indefinitely.
To proceed, I excluded this specific test using --deselect=./slack_sdk_async/socket_mode/test_interactions_aiohttp.py and ran the full suite successfully.
I'd like your feedback on this update before submitting the PR. Let me know if there are any concerns or suggestions regarding the changes or the test behavior.
Thank you!
Hi @HTSagara thanks for looking into this 💯
It is important to take our time with this issue since there may be unknown edge cases affected by these changes. They may also touch the critical path of the project.
Taking a quick look at the changes you've made so far, it seem like they also need to be made to the async_base_client.py
Feel free to open a PR when the unit tests pass on your local, should make it easier to review and give feedback
Resolved by #1598