python-slack-sdk icon indicating copy to clipboard operation
python-slack-sdk copied to clipboard

bug: improve the slack url overwriting experience

Open WilliamBergamin opened this issue 1 year ago • 2 comments

(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))

  1. Try setting up an app to point to a different slack url that does not include a trailing /
  2. app = App(token=os.environ.get("SLACK_BOT_TOKEN"), client=WebClient(os.environ.get("SLACK_BOT_TOKEN"), "https://example.slack.com/api"))
  3. This will fail 🔴
  4. 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/"))
  5. 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 avatar Aug 12 '24 21:08 WilliamBergamin

@WilliamBergamin This idea should be helpful in some situations, but it sounds like an improvement on the slack-sdk side. What do you think?

seratch avatar Aug 13 '24 00:08 seratch

I moved the issue over to python-slack-sdk

filmaj avatar Aug 13 '24 12:08 filmaj

Hi, can I work on this issue?

HTSagara avatar Nov 15 '24 17:11 HTSagara

Hi everyone,

I've made a change to address an issue in the base URL handling in the SDK. Specifically:

  1. Changes in base_client.py:

    • Updated the code to ensure the base_url ends with a / if it's not already present.
    • See the relevant change here: base_client.py.
  2. Added Tests in test_web_client.py:

    • Added test cases to validate the updated base_url behavior.
    • You can find the new tests here: test_web_client.py.

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!

HTSagara avatar Nov 16 '24 21:11 HTSagara

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

WilliamBergamin avatar Nov 18 '24 15:11 WilliamBergamin

Resolved by #1598

seratch avatar Dec 05 '24 03:12 seratch