Skip to content

Commit 4044d5a

Browse files
committed
Improve the warning message in App/AsyncApp constructor #256
1 parent e80a21c commit 4044d5a

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

slack_bolt/app/app.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
error_authorize_conflicts,
4545
warning_bot_only_conflicts,
4646
debug_return_listener_middleware_response,
47+
info_default_oauth_settings_loaded,
4748
)
4849
from slack_bolt.middleware import (
4950
Middleware,
@@ -174,7 +175,11 @@ def __init__(
174175
# initialize with the default settings
175176
oauth_settings = OAuthSettings()
176177

177-
if oauth_flow:
178+
if oauth_flow is None and installation_store is None:
179+
# show info-level log for avoiding confusions
180+
self._framework_logger.info(info_default_oauth_settings_loaded())
181+
182+
if oauth_flow is not None:
178183
self._oauth_flow = oauth_flow
179184
installation_store = select_consistent_installation_store(
180185
client_id=self._oauth_flow.client_id,

slack_bolt/app/async_app.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
error_oauth_flow_invalid_type_async,
4646
warning_bot_only_conflicts,
4747
debug_return_listener_middleware_response,
48+
info_default_oauth_settings_loaded,
4849
)
4950
from slack_bolt.lazy_listener.asyncio_runner import AsyncioLazyListenerRunner
5051
from slack_bolt.listener.async_listener import AsyncListener, AsyncCustomListener
@@ -184,6 +185,10 @@ def __init__(
184185
# initialize with the default settings
185186
oauth_settings = AsyncOAuthSettings()
186187

188+
if oauth_flow is None and installation_store is None:
189+
# show info-level log for avoiding confusions
190+
self._framework_logger.info(info_default_oauth_settings_loaded())
191+
187192
if oauth_flow:
188193
if not isinstance(oauth_flow, AsyncOAuthFlow):
189194
raise BoltError(error_oauth_flow_invalid_type_async())

slack_bolt/logger/messages.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ def warning_client_prioritized_and_token_skipped() -> str:
6969

7070
def warning_token_skipped() -> str:
7171
return (
72-
"As you gave `installation_store`/`authorize` as well, `token` will be unused."
72+
"As either `installation_store` or `authorize` is enabled, "
73+
"`token` (or SLACK_BOT_TOKEN env variable) will be unused."
7374
)
7475

7576

@@ -104,6 +105,16 @@ def warning_skip_uncommon_arg_name(arg_name: str) -> str:
104105
# -------------------------------
105106

106107

108+
def info_default_oauth_settings_loaded() -> str:
109+
return (
110+
"As you've set SLACK_CLIENT_ID and SLACK_CLIENT_SECRET env variables, "
111+
"Bolt enabled file-based InstallationStore/OAuthStateStore for you. "
112+
"Note that the file based ones are for local development. "
113+
"If you want to use a different datastore, set oauth_settings argument in App constructor. "
114+
"Refer to https://slack.dev/bolt-python/concepts#authenticating-oauth for more details."
115+
)
116+
117+
107118
# -------------------------------
108119
# Debug
109120
# -------------------------------

0 commit comments

Comments
 (0)