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

add trailing slash to the end of the url #1594

Merged
merged 4 commits into from
Nov 19, 2024

Conversation

HTSagara
Copy link
Contributor

Summary

This PR addresses issue #1541 by ensuring that a trailing / is appended to the end of the URL in base_url if it is not already provided. This change ensures consistent URL formatting and avoids potential issues caused by missing trailing slashes in API calls.

Testing

  1. Unit Tests
    Run the following command to ensure all relevant test cases pass:
./scripts/run_unit_tests.sh tests/slack_sdk/web/test_web_client.py
  1. Manual Testing
  • Use a custom base_url without a trailing / in a sample implementation. Confirm that the URL is automatically appended with a / during API calls.
  • Use a base_url with a trailing / and verify that no additional / is appended.

Category

  • [x ] 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 (Documents)
  • /tutorial (PythOnBoardingBot tutorial)
  • tests/integration_tests (Automated tests for this library)

Requirements

  • [x ] I've read and understood the Contributing Guidelines and have done my best effort to follow them.
  • [x ] I've read and agree to the Code of Conduct.
  • [x ] 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 Nov 19, 2024
@seratch seratch added this to the 3.x milestone Nov 19, 2024
@seratch seratch self-assigned this Nov 19, 2024
Copy link
Member

@seratch seratch left a comment

Choose a reason for hiding this comment

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

Thanks for taking the time to make this PR! Can you apply the same change to legacy_base_client.py for consistency?

slack_sdk/web/async_base_client.py Outdated Show resolved Hide resolved
slack_sdk/web/base_client.py Outdated Show resolved Hide resolved
Copy link
Member

@seratch seratch left a comment

Choose a reason for hiding this comment

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

LGTM; I will be offline for a while but other maintainers will merge this once the CI builds pass. Thank you for taking the time to fix this issue!

@seratch seratch modified the milestones: 3.x, 3.33.5 Nov 19, 2024
Copy link

codecov bot commented Nov 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.89%. Comparing base (d1dffb7) to head (b491388).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1594      +/-   ##
==========================================
- Coverage   84.91%   84.89%   -0.03%     
==========================================
  Files         113      113              
  Lines       12622    12628       +6     
==========================================
+ Hits        10718    10720       +2     
- Misses       1904     1908       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

Copy link
Contributor

@WilliamBergamin WilliamBergamin left a comment

Choose a reason for hiding this comment

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

lgtm, thank you 💯

@WilliamBergamin WilliamBergamin merged commit c82c9a0 into slackapi:main Nov 19, 2024
12 checks passed
@HTSagara
Copy link
Contributor Author

Thank you for all the support 🙏

@HTSagara
Copy link
Contributor Author

HTSagara commented Nov 19, 2024

Hi @WilliamBergamin and @seratch I noticed that after I changed the legacy_base_client.py it caused an error by adding a (//) in the api_url when concatenating the base_url with the api_method.

I just submitted the issue with the PR #1596 in order to fix it.

Apologies for the mistake.

@WilliamBergamin
Copy link
Contributor

No worries 🤔 I had a feeling these changes may affect more edge cases then we could think of

My concern is that our unit tests did not catch this edge case and may have missed others that we are unaware of, It may be simpler to revert this commit, add more tests around this area in a separate PR and reopen these changes with updates to the tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla:signed 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.

3 participants