Skip to content

Commit 0b14ab1

Browse files
fix: resolve OAuth installation store bugs and typos
1 parent 9435412 commit 0b14ab1

5 files changed

Lines changed: 29 additions & 18 deletions

File tree

slack_sdk/oauth/installation_store/amazon_s3/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def save(self, installation: Installation):
106106

107107
def save_bot(self, bot: Bot):
108108
if bot.bot_token is None:
109-
self.logger.debug("Skipped saving a new row because of the absense of bot token in it")
109+
self.logger.debug("Skipped saving a new row because of the absence of bot token in it")
110110
return
111111

112112
none = "none"
@@ -273,7 +273,7 @@ def delete_bot(self, *, enterprise_id: Optional[str], team_id: Optional[str]) ->
273273
Key=content.get("Key"),
274274
)
275275
except Exception as e:
276-
message = f"Failed to find bot installation data for enterprise: {e_id}, team: {t_id}: {e}"
276+
message = f"Failed to delete bot installation data for enterprise: {e_id}, team: {t_id}: {e}"
277277
raise SlackClientConfigurationError(message)
278278

279279
async def async_delete_installation(
@@ -316,7 +316,7 @@ def delete_installation(
316316
)
317317
deleted_keys.append(key)
318318
except Exception as e:
319-
message = f"Failed to find bot installation data for enterprise: {e_id}, team: {t_id}: {e}"
319+
message = f"Failed to delete installation data for enterprise: {e_id}, team: {t_id}: {e}"
320320
raise SlackClientConfigurationError(message)
321321

322322
try:
@@ -328,7 +328,7 @@ def delete_installation(
328328
)
329329
deleted_keys.append(no_user_id_key)
330330
except Exception as e:
331-
message = f"Failed to find bot installation data for enterprise: {e_id}, team: {t_id}: {e}"
331+
message = f"Failed to delete installation data for enterprise: {e_id}, team: {t_id}: {e}"
332332
raise SlackClientConfigurationError(message)
333333

334334
# Check the remaining installation data
@@ -347,5 +347,5 @@ def delete_installation(
347347
Key=content.get("Key"),
348348
)
349349
except Exception as e:
350-
message = f"Failed to find bot installation data for enterprise: {e_id}, team: {t_id}: {e}"
350+
message = f"Failed to delete installation data for enterprise: {e_id}, team: {t_id}: {e}"
351351
raise SlackClientConfigurationError(message)

slack_sdk/oauth/installation_store/async_cacheable_installation_store.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ async def async_delete_bot(
9898
team_id=team_id,
9999
)
100100
key = f"{enterprise_id or ''}-{team_id or ''}"
101-
self.cached_bots.pop(key)
101+
if key in self.cached_bots:
102+
self.cached_bots.pop(key)
102103

103104
async def async_delete_installation(
104105
self,

slack_sdk/oauth/installation_store/file/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def save(self, installation: Installation):
7878

7979
def save_bot(self, bot: Bot):
8080
if bot.bot_token is None:
81-
self.logger.debug("Skipped saving a new row because of the absense of bot token in it")
81+
self.logger.debug("Skipped saving a new row because of the absence of bot token in it")
8282
return
8383

8484
none = "none"

slack_sdk/oauth/installation_store/sqlite3/__init__.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ def connect(self) -> Connection:
4848

4949
def create_tables(self):
5050
with sqlite3.connect(database=self.database) as conn:
51-
conn.execute("""
51+
conn.execute(
52+
"""
5253
create table slack_installations (
5354
id integer primary key autoincrement,
5455
client_id text not null,
@@ -77,17 +78,21 @@ def create_tables(self):
7778
token_type text,
7879
installed_at datetime not null default current_timestamp
7980
);
80-
""")
81-
conn.execute("""
81+
"""
82+
)
83+
conn.execute(
84+
"""
8285
create index slack_installations_idx on slack_installations (
8386
client_id,
8487
enterprise_id,
8588
team_id,
8689
user_id,
8790
installed_at
8891
);
89-
""")
90-
conn.execute("""
92+
"""
93+
)
94+
conn.execute(
95+
"""
9196
create table slack_bots (
9297
id integer primary key autoincrement,
9398
client_id text not null,
@@ -105,15 +110,18 @@ def create_tables(self):
105110
is_enterprise_install boolean not null default 0,
106111
installed_at datetime not null default current_timestamp
107112
);
108-
""")
109-
conn.execute("""
113+
"""
114+
)
115+
conn.execute(
116+
"""
110117
create index slack_bots_idx on slack_bots (
111118
client_id,
112119
enterprise_id,
113120
team_id,
114121
installed_at
115122
);
116-
""")
123+
"""
124+
)
117125
self.logger.debug(f"Tables have been created (database: {self.database})")
118126
conn.commit()
119127

@@ -217,7 +225,7 @@ def save(self, installation: Installation):
217225

218226
def save_bot(self, bot: Bot):
219227
if bot.bot_token is None:
220-
self.logger.debug("Skipped saving a new row because of the absense of bot token in it")
228+
self.logger.debug("Skipped saving a new row because of the absence of bot token in it")
221229
return
222230

223231
with self.connect() as conn:

slack_sdk/oauth/state_store/sqlite3/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,15 @@ def connect(self) -> Connection:
4545

4646
def create_tables(self):
4747
with sqlite3.connect(database=self.database) as conn:
48-
conn.execute("""
48+
conn.execute(
49+
"""
4950
create table oauth_states (
5051
id integer primary key autoincrement,
5152
state text not null,
5253
expire_at datetime not null
5354
);
54-
""")
55+
"""
56+
)
5557
self.logger.debug(f"Tables have been created (database: {self.database})")
5658
conn.commit()
5759

0 commit comments

Comments
 (0)