Skip to content

Commit e53d64b

Browse files
committed
return dynamo item
1 parent 20538da commit e53d64b

File tree

5 files changed

+35
-33
lines changed

5 files changed

+35
-33
lines changed

packages/slackBotFunction/app/services/dynamo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
def get_state_information(key):
55
table = get_slack_bot_state_table()
6-
table.get_item(Key=key)
6+
return table.get_item(Key=key)
77

88

99
def store_state_information(item, condition=None):

packages/slackBotFunction/app/slack/slack_events.py

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ def cleanup_previous_unfeedback_qa(conversation_key, current_message_ts, session
4545
)
4646
logger.info("Deleted unfeedback Q&A for privacy", extra={"message_ts": previous_message_ts})
4747

48-
except ClientError as e:
48+
except ClientError:
4949
if e.response.get("Error", {}).get("Code") == "ConditionalCheckFailedException":
5050
logger.info("Q&A has feedback - keeping for user", extra={"message_ts": previous_message_ts})
5151
else:
52-
logger.error("Error cleaning up Q&A", extra={"error": str(e)})
53-
except Exception as e:
54-
logger.error("Error cleaning up unfeedback Q&A", extra={"error": str(e)})
52+
logger.error("Error cleaning up Q&A", extra={"error": traceback.format_exc()})
53+
except Exception:
54+
logger.error("Error cleaning up unfeedback Q&A", extra={"error": traceback.format_exc()})
5555

5656

5757
def store_qa_pair(conversation_key, user_query, bot_response, message_ts, session_id, user_id):
@@ -72,8 +72,8 @@ def store_qa_pair(conversation_key, user_query, bot_response, message_ts, sessio
7272
}
7373
store_state_information(item=item)
7474
logger.info("Stored Q&A pair", extra={"conversation_key": conversation_key, "message_ts": message_ts})
75-
except Exception as e:
76-
logger.error("Failed to store Q&A pair", extra={"error": str(e)})
75+
except Exception:
76+
logger.error("Failed to store Q&A pair", extra={"error": traceback.format_exc()})
7777

7878

7979
def _mark_qa_feedback_received(conversation_key, message_ts):
@@ -86,8 +86,8 @@ def _mark_qa_feedback_received(conversation_key, message_ts):
8686
"SET feedback_received = :val",
8787
{":val": True},
8888
)
89-
except Exception as e:
90-
logger.error("Error marking Q&A feedback received", extra={"error": str(e)})
89+
except Exception:
90+
logger.error("Error marking Q&A feedback received", extra={"error": traceback.format_exc()})
9191

9292

9393
# ================================================================
@@ -238,7 +238,8 @@ def process_async_slack_event(slack_event_data):
238238
client.chat_update(channel=channel, ts=message_ts, text=response_text, blocks=blocks)
239239
except Exception as e:
240240
logger.error(
241-
f"Failed to attach feedback buttons: {e}", extra={"event_id": event_id, "message_ts": message_ts}
241+
f"Failed to attach feedback buttons: {e}",
242+
extra={"event_id": event_id, "message_ts": message_ts, "error": traceback.format_exc()},
242243
)
243244

244245
except Exception:
@@ -250,8 +251,8 @@ def process_async_slack_event(slack_event_data):
250251
if thread_ts: # Only add thread_ts for channel threads, not DMs
251252
post_params["thread_ts"] = thread_ts
252253
client.chat_postMessage(**post_params)
253-
except Exception as post_err:
254-
logger.error("Failed to post error message", extra={"error": str(post_err)})
254+
except Exception:
255+
logger.error("Failed to post error message", extra={"error": traceback.format_exc()})
255256

256257

257258
# ================================================================
@@ -332,10 +333,10 @@ def store_feedback(
332333
)
333334

334335
except ClientError as e:
335-
logger.error(f"Error storing feedback: {e}")
336+
logger.error(f"Error storing feedback: {e}", extra={"error": traceback.format_exc()})
336337
raise
337338
except Exception as e:
338-
logger.error(f"Error storing feedback: {e}")
339+
logger.error(f"Error storing feedback: {e}", extra={"error": traceback.format_exc()})
339340

340341

341342
# ================================================================
@@ -375,8 +376,8 @@ def get_latest_message_ts(conversation_key):
375376
if "Item" in response:
376377
return response["Item"].get("latest_message_ts")
377378
return None
378-
except Exception as e:
379-
logger.error("Error getting latest message timestamp", extra={"error": str(e)})
379+
except Exception:
380+
logger.error("Error getting latest message timestamp", extra={"error": traceback.format_exc()})
380381
return None
381382

382383

@@ -420,5 +421,5 @@ def update_session_latest_message(conversation_key, message_ts):
420421
"SET latest_message_ts = :ts",
421422
{":ts": message_ts},
422423
)
423-
except Exception as e:
424-
logger.error("Error updating session latest message", extra={"error": str(e)})
424+
except Exception:
425+
logger.error("Error updating session latest message", extra={"error": traceback.format_exc()})

packages/slackBotFunction/app/slack/slack_handlers.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import json
1111
import re
1212
from functools import lru_cache
13+
import traceback
1314
from botocore.exceptions import ClientError
1415
from app.core.config import (
1516
get_bot_messages,
@@ -113,7 +114,7 @@ def mention_handler(event, ack, body, client):
113114
feedback_text,
114115
)
115116
except Exception as e:
116-
logger.error(f"Failed to store channel feedback via mention: {e}")
117+
logger.error(f"Failed to store channel feedback via mention: {e}", extra={"error": traceback.format_exc()})
117118
BOT_MESSAGES = get_bot_messages()
118119
try:
119120
client.chat_postMessage(
@@ -122,7 +123,7 @@ def mention_handler(event, ack, body, client):
122123
thread_ts=thread_root,
123124
)
124125
except Exception as e:
125-
logger.error(f"Failed to post channel feedback ack: {e}")
126+
logger.error(f"Failed to post channel feedback ack: {e}", extra={"error": traceback.format_exc()})
126127
return
127128

128129
# Normal mention -> async processing
@@ -158,7 +159,7 @@ def dm_message_handler(event, event_id, client):
158159
feedback_text,
159160
)
160161
except Exception as e:
161-
logger.error(f"Failed to store DM additional feedback: {e}")
162+
logger.error(f"Failed to store DM additional feedback: {e}", extra={"error": traceback.format_exc()})
162163
BOT_MESSAGES = get_bot_messages()
163164

164165
try:
@@ -168,7 +169,7 @@ def dm_message_handler(event, event_id, client):
168169
text=BOT_MESSAGES["feedback_thanks"],
169170
)
170171
except Exception as e:
171-
logger.error(f"Failed to post DM feedback ack: {e}")
172+
logger.error(f"Failed to post DM feedback ack: {e}", extra={"error": traceback.format_exc()})
172173
return
173174

174175
# Normal DM -> async processing
@@ -200,7 +201,7 @@ def thread_message_handler(event, event_id, client):
200201
return # not a bot-owned thread; ignore
201202
logger.info(f"Found session for thread: {conversation_key}")
202203
except Exception as e:
203-
logger.error(f"Error checking thread session: {e}")
204+
logger.error(f"Error checking thread session: {e}", extra={"error": traceback.format_exc()})
204205
return
205206

206207
if text.lower().startswith(constants.FEEDBACK_PREFIX):
@@ -217,7 +218,7 @@ def thread_message_handler(event, event_id, client):
217218
feedback_text,
218219
)
219220
except Exception as e:
220-
logger.error(f"Failed to store channel additional feedback: {e}")
221+
logger.error(f"Failed to store channel additional feedback: {e}", extra={"error": traceback.format_exc()})
221222

222223
try:
223224
BOT_MESSAGES = get_bot_messages()
@@ -228,7 +229,7 @@ def thread_message_handler(event, event_id, client):
228229
thread_ts=thread_root,
229230
)
230231
except Exception as e:
231-
logger.error(f"Failed to post channel feedback ack: {e}")
232+
logger.error(f"Failed to post channel feedback ack: {e}", extra={"error": traceback.format_exc()})
232233
return
233234

234235
# Follow-up in a bot-owned thread (no re-mention required)
@@ -302,11 +303,11 @@ def feedback_handler(ack, body, client):
302303
# Silently ignore duplicate votes - user already voted on this message
303304
logger.info(f"Duplicate vote ignored for user {body['user']['id']}")
304305
return
305-
logger.error(f"Feedback storage error: {e}")
306+
logger.error(f"Feedback storage error: {e}", extra={"error": traceback.format_exc()})
306307
except Exception as e:
307-
logger.error(f"Unexpected feedback error: {e}")
308+
logger.error(f"Unexpected feedback error: {e}", extra={"error": traceback.format_exc()})
308309
except Exception as e:
309-
logger.error(f"Error handling feedback: {e}")
310+
logger.error(f"Error handling feedback: {e}", extra={"error": traceback.format_exc()})
310311

311312

312313
# ================================================================
@@ -337,5 +338,5 @@ def _is_latest_message(conversation_key, message_ts):
337338
return latest_message_ts == message_ts
338339
return False
339340
except Exception as e:
340-
logger.error(f"Error checking latest message: {e}")
341+
logger.error(f"Error checking latest message: {e}", extra={"error": traceback.format_exc()})
341342
return False

scripts/run_sync.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ EPSAM_CONFIG=".local_config/epsam_app.config.json"
1010
EPSAM_LOG=".local_config/epsam_app.log"
1111

1212
if [ -z "${PULL_REQUEST_ID}" ]; then
13-
echo "What is the pull request id?"
13+
echo "What is the pull request id? "
1414
read -r PULL_REQUEST_ID
1515
else
16-
read -r -p "Getting exports for pull request id ${PULL_REQUEST_ID}. Is this correct?" yn
16+
read -r -p "Getting exports for pull request id ${PULL_REQUEST_ID}. Is this correct? " yn
1717
case $yn in
1818
[Yy]* ) ;;
1919
[Nn]* ) exit;;

scripts/sync_docs.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
set -e
33

44
if [ -z "${PULL_REQUEST_ID}" ]; then
5-
echo "What is the pull request id?"
5+
echo "What is the pull request id? "
66
read -r PULL_REQUEST_ID
77
else
8-
read -r -p "Getting exports for pull request id ${PULL_REQUEST_ID}. Is this correct?" yn
8+
read -r -p "Getting exports for pull request id ${PULL_REQUEST_ID}. Is this correct? " yn
99
case $yn in
1010
[Yy]* ) ;;
1111
[Nn]* ) exit;;

0 commit comments

Comments
 (0)