From 0b14ab113b7f50bc898a975af544b79d252b97a2 Mon Sep 17 00:00:00 2001 From: William Bergamin Date: Tue, 28 Apr 2026 12:33:01 -0400 Subject: [PATCH 1/3] fix: resolve OAuth installation store bugs and typos --- .../installation_store/amazon_s3/__init__.py | 10 +++---- .../async_cacheable_installation_store.py | 3 ++- .../oauth/installation_store/file/__init__.py | 2 +- .../installation_store/sqlite3/__init__.py | 26 ++++++++++++------- .../oauth/state_store/sqlite3/__init__.py | 6 +++-- 5 files changed, 29 insertions(+), 18 deletions(-) diff --git a/slack_sdk/oauth/installation_store/amazon_s3/__init__.py b/slack_sdk/oauth/installation_store/amazon_s3/__init__.py index c5c420f12..9a915c77c 100644 --- a/slack_sdk/oauth/installation_store/amazon_s3/__init__.py +++ b/slack_sdk/oauth/installation_store/amazon_s3/__init__.py @@ -106,7 +106,7 @@ def save(self, installation: Installation): def save_bot(self, bot: Bot): if bot.bot_token is None: - self.logger.debug("Skipped saving a new row because of the absense of bot token in it") + self.logger.debug("Skipped saving a new row because of the absence of bot token in it") return none = "none" @@ -273,7 +273,7 @@ def delete_bot(self, *, enterprise_id: Optional[str], team_id: Optional[str]) -> Key=content.get("Key"), ) except Exception as e: - message = f"Failed to find bot installation data for enterprise: {e_id}, team: {t_id}: {e}" + message = f"Failed to delete bot installation data for enterprise: {e_id}, team: {t_id}: {e}" raise SlackClientConfigurationError(message) async def async_delete_installation( @@ -316,7 +316,7 @@ def delete_installation( ) deleted_keys.append(key) except Exception as e: - message = f"Failed to find bot installation data for enterprise: {e_id}, team: {t_id}: {e}" + message = f"Failed to delete installation data for enterprise: {e_id}, team: {t_id}: {e}" raise SlackClientConfigurationError(message) try: @@ -328,7 +328,7 @@ def delete_installation( ) deleted_keys.append(no_user_id_key) except Exception as e: - message = f"Failed to find bot installation data for enterprise: {e_id}, team: {t_id}: {e}" + message = f"Failed to delete installation data for enterprise: {e_id}, team: {t_id}: {e}" raise SlackClientConfigurationError(message) # Check the remaining installation data @@ -347,5 +347,5 @@ def delete_installation( Key=content.get("Key"), ) except Exception as e: - message = f"Failed to find bot installation data for enterprise: {e_id}, team: {t_id}: {e}" + message = f"Failed to delete installation data for enterprise: {e_id}, team: {t_id}: {e}" raise SlackClientConfigurationError(message) diff --git a/slack_sdk/oauth/installation_store/async_cacheable_installation_store.py b/slack_sdk/oauth/installation_store/async_cacheable_installation_store.py index 935d24fe4..4edc638ef 100644 --- a/slack_sdk/oauth/installation_store/async_cacheable_installation_store.py +++ b/slack_sdk/oauth/installation_store/async_cacheable_installation_store.py @@ -98,7 +98,8 @@ async def async_delete_bot( team_id=team_id, ) key = f"{enterprise_id or ''}-{team_id or ''}" - self.cached_bots.pop(key) + if key in self.cached_bots: + self.cached_bots.pop(key) async def async_delete_installation( self, diff --git a/slack_sdk/oauth/installation_store/file/__init__.py b/slack_sdk/oauth/installation_store/file/__init__.py index e178048b4..aa6f6c52d 100644 --- a/slack_sdk/oauth/installation_store/file/__init__.py +++ b/slack_sdk/oauth/installation_store/file/__init__.py @@ -78,7 +78,7 @@ def save(self, installation: Installation): def save_bot(self, bot: Bot): if bot.bot_token is None: - self.logger.debug("Skipped saving a new row because of the absense of bot token in it") + self.logger.debug("Skipped saving a new row because of the absence of bot token in it") return none = "none" diff --git a/slack_sdk/oauth/installation_store/sqlite3/__init__.py b/slack_sdk/oauth/installation_store/sqlite3/__init__.py index 6e65805fe..baad41e6c 100644 --- a/slack_sdk/oauth/installation_store/sqlite3/__init__.py +++ b/slack_sdk/oauth/installation_store/sqlite3/__init__.py @@ -48,7 +48,8 @@ def connect(self) -> Connection: def create_tables(self): with sqlite3.connect(database=self.database) as conn: - conn.execute(""" + conn.execute( + """ create table slack_installations ( id integer primary key autoincrement, client_id text not null, @@ -77,8 +78,10 @@ def create_tables(self): token_type text, installed_at datetime not null default current_timestamp ); - """) - conn.execute(""" + """ + ) + conn.execute( + """ create index slack_installations_idx on slack_installations ( client_id, enterprise_id, @@ -86,8 +89,10 @@ def create_tables(self): user_id, installed_at ); - """) - conn.execute(""" + """ + ) + conn.execute( + """ create table slack_bots ( id integer primary key autoincrement, client_id text not null, @@ -105,15 +110,18 @@ def create_tables(self): is_enterprise_install boolean not null default 0, installed_at datetime not null default current_timestamp ); - """) - conn.execute(""" + """ + ) + conn.execute( + """ create index slack_bots_idx on slack_bots ( client_id, enterprise_id, team_id, installed_at ); - """) + """ + ) self.logger.debug(f"Tables have been created (database: {self.database})") conn.commit() @@ -217,7 +225,7 @@ def save(self, installation: Installation): def save_bot(self, bot: Bot): if bot.bot_token is None: - self.logger.debug("Skipped saving a new row because of the absense of bot token in it") + self.logger.debug("Skipped saving a new row because of the absence of bot token in it") return with self.connect() as conn: diff --git a/slack_sdk/oauth/state_store/sqlite3/__init__.py b/slack_sdk/oauth/state_store/sqlite3/__init__.py index 3a18c4682..8a82e333f 100644 --- a/slack_sdk/oauth/state_store/sqlite3/__init__.py +++ b/slack_sdk/oauth/state_store/sqlite3/__init__.py @@ -45,13 +45,15 @@ def connect(self) -> Connection: def create_tables(self): with sqlite3.connect(database=self.database) as conn: - conn.execute(""" + conn.execute( + """ create table oauth_states ( id integer primary key autoincrement, state text not null, expire_at datetime not null ); - """) + """ + ) self.logger.debug(f"Tables have been created (database: {self.database})") conn.commit() From f4b26284168249af211ca26fb90f8f4b4ab98a8c Mon Sep 17 00:00:00 2001 From: William Bergamin Date: Tue, 28 Apr 2026 12:37:37 -0400 Subject: [PATCH 2/3] clean up changes --- .../installation_store/sqlite3/__init__.py | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/slack_sdk/oauth/installation_store/sqlite3/__init__.py b/slack_sdk/oauth/installation_store/sqlite3/__init__.py index baad41e6c..42f9c6ad8 100644 --- a/slack_sdk/oauth/installation_store/sqlite3/__init__.py +++ b/slack_sdk/oauth/installation_store/sqlite3/__init__.py @@ -48,8 +48,7 @@ def connect(self) -> Connection: def create_tables(self): with sqlite3.connect(database=self.database) as conn: - conn.execute( - """ + conn.execute(""" create table slack_installations ( id integer primary key autoincrement, client_id text not null, @@ -78,10 +77,8 @@ def create_tables(self): token_type text, installed_at datetime not null default current_timestamp ); - """ - ) - conn.execute( - """ + """) + conn.execute(""" create index slack_installations_idx on slack_installations ( client_id, enterprise_id, @@ -89,10 +86,8 @@ def create_tables(self): user_id, installed_at ); - """ - ) - conn.execute( - """ + """) + conn.execute(""" create table slack_bots ( id integer primary key autoincrement, client_id text not null, @@ -110,18 +105,15 @@ def create_tables(self): is_enterprise_install boolean not null default 0, installed_at datetime not null default current_timestamp ); - """ - ) - conn.execute( - """ + """) + conn.execute(""" create index slack_bots_idx on slack_bots ( client_id, enterprise_id, team_id, installed_at ); - """ - ) + """) self.logger.debug(f"Tables have been created (database: {self.database})") conn.commit() From ecb61e5e96bb991b86667aaf7eb09d5e4d0f082e Mon Sep 17 00:00:00 2001 From: William Bergamin Date: Tue, 28 Apr 2026 12:38:30 -0400 Subject: [PATCH 3/3] Update __init__.py --- slack_sdk/oauth/state_store/sqlite3/__init__.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/slack_sdk/oauth/state_store/sqlite3/__init__.py b/slack_sdk/oauth/state_store/sqlite3/__init__.py index 8a82e333f..3a18c4682 100644 --- a/slack_sdk/oauth/state_store/sqlite3/__init__.py +++ b/slack_sdk/oauth/state_store/sqlite3/__init__.py @@ -45,15 +45,13 @@ def connect(self) -> Connection: def create_tables(self): with sqlite3.connect(database=self.database) as conn: - conn.execute( - """ + conn.execute(""" create table oauth_states ( id integer primary key autoincrement, state text not null, expire_at datetime not null ); - """ - ) + """) self.logger.debug(f"Tables have been created (database: {self.database})") conn.commit()