Repository navigation
feat: default the client base_url from SLACK_API_URL - #1639
Conversation
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1639 +/- ##
=======================================
Coverage 91.57% 91.57%
=======================================
Files 228 228
Lines 7287 7289 +2
=======================================
+ Hits 6673 6675 +2
Misses 614 614 ☔ View full report in Codecov by Harness. |
cchensh
left a comment
There was a problem hiding this comment.
Checked at 5066d15.
- Imports:
osis already imported in both app modules. - Client reuse: the per-request client copies
self._client.base_url. Socket Mode adapters default toapp.client. App-levelinstallation_storeandoauth_settingsflows getclient=self.client.say, function tokens and the assistant thread store all usecontext.client. - Trailing slash: slack_sdk appends a trailing
/tobase_urlwhen it's missing, so a value without one is harmless. - Parity: this matches bolt-js#3164 for an empty value and for a given client.
Nits: the "OAuth ... reuse the app's client" bullet is a little broad. Two paths still build their own client at the default URL. Both are existing gaps for any custom base_url, not something this PR introduces, but worth a note or a follow-up:
OAuthSettings/AsyncOAuthSettingsbuildInstallationStoreAuthorize(...)with noclient(oauth_settings.py:140,async_oauth_settings.py:147). So theTokenRotatorrefresh calls go toslack.com.OAuthFlow.sqlite3()/AsyncOAuthFlow.sqlite3()passclient=client or WebClient()(oauth_flow.py:132,async_oauth_flow.py:137). That skips the app's fill-in, so the OAuth callback'soauth.v2.accessgoes toslack.com.
WilliamBergamin
left a comment
There was a problem hiding this comment.
🧪 Thanks @zimeg! The empty SLACK_API_URL and passed-in client tests pin exactly the two cases that would surprise folks, in both sync and async.
Left two optional comments, nothing blocking 💯
Co-authored-by: William Bergamin <25348381+WilliamBergamin@users.noreply.github.com> Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
WilliamBergamin
left a comment
There was a problem hiding this comment.
🧪 Thanks @zimeg! Moving the lookup into the shared helpers means the standalone OAuth flows follow SLACK_API_URL too, and the new tests pin that for sync and async. Fair point on the docstring feeding the reference docs.
One optional cleanup left, nothing blocking 💯
Co-authored-by: William Bergamin <25348381+WilliamBergamin@users.noreply.github.com> Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
WilliamBergamin
left a comment
There was a problem hiding this comment.
📚 Thanks @zimeg! With the param gone the helpers match main again, and the new docs line is right about the trailing slash, since the SDK adds it.
No more comments from me 🚀
|
🌟 Thanks for the kind reviews @WilliamBergamin, @cchensh and @mwbrooks! |
Summary
This pull request makes the client that
AppandAsyncAppcreate default itsbase_urlto theSLACK_API_URLenvironment variable when that variable is set and not empty. It's the Python twin of slackapi/bolt-js#3164.clientyou pass in keeps its ownbase_url.SLACK_API_URLkeeps the defaulthttps://slack.com/api/.SLACK_API_URLfor the selected API host, so apps started with the CLI reach that host.OAuthFlow,AsyncOAuthFloworLambdaS3OAuthFlowbuilds its default client with the same helpers, so it followsSLACK_API_URLtoo.OAuthFlowbuilt fromoauth_settingsalready reuse the app's client, so they pick up the samebase_url. Token rotation underoauth_settingsandOAuthFlow.sqlite3()still build their own default client. That was already true for any custombase_url, and it's tracked in OAuth token rotation and OAuthFlow.sqlite3() ignore the app client's base_url and proxy #1640.clientdocstring and the "Using the Web API" docs page note the new default.Testing
SLACK_API_URL=https://qa.slack.com/api/ python -c "from slack_bolt import App; print(App(token='xoxb-example', signing_secret='example', token_verification_enabled=False).client.base_url)"https://qa.slack.com/api/.SLACK_API_URL, or withSLACK_API_URL=. It printshttps://slack.com/api/.slack runagainst a non-production API host and confirm Web API calls go to that host.Category
slack_bolt.Appand/or its core componentsslack_bolt.async_app.AsyncAppand/or its core componentsslack_bolt.adapter/docsRequirements
./scripts/install_all_and_run_tests.shafter making the changes.🤖 Generated with Claude Code