From df7ab83cb4da5471ae7e4f0aa6423a6e0a3149f1 Mon Sep 17 00:00:00 2001 From: Mish Date: Thu, 20 Nov 2025 13:06:22 +0000 Subject: [PATCH] Handle exceptions from reactions_remove() calls (#119) This is because I noticed this part of the code failing in the prod logs --- nephthys/actions/resolve.py | 17 ++++++++++++----- nephthys/macros/reopen.py | 17 ++++++++++++----- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/nephthys/actions/resolve.py b/nephthys/actions/resolve.py index d472fde..e5ffcab 100644 --- a/nephthys/actions/resolve.py +++ b/nephthys/actions/resolve.py @@ -1,5 +1,7 @@ +import logging from datetime import datetime +from slack_sdk.errors import SlackApiError from slack_sdk.web.async_client import AsyncWebClient from nephthys.utils.delete_thread import add_thread_to_delete_queue @@ -79,11 +81,16 @@ async def resolve( timestamp=ts, ) - await client.reactions_remove( - channel=env.slack_help_channel, - name="thinking_face", - timestamp=ts, - ) + try: + await client.reactions_remove( + channel=env.slack_help_channel, + name="thinking_face", + timestamp=ts, + ) + except SlackApiError as e: + logging.error( + f"Failed to remove thinking reaction from ticket with ts {ts}: {e.response['error']}" + ) if await env.workspace_admin_available(): await add_thread_to_delete_queue( diff --git a/nephthys/macros/reopen.py b/nephthys/macros/reopen.py index ce28299..d0dc790 100644 --- a/nephthys/macros/reopen.py +++ b/nephthys/macros/reopen.py @@ -1,5 +1,7 @@ import logging +from slack_sdk.errors import SlackApiError + from nephthys.macros.types import Macro from nephthys.utils.env import env from nephthys.utils.logging import send_heartbeat @@ -86,11 +88,16 @@ class Reopen(Macro): data={"ticketTs": new_ticket_ts}, ) - await env.slack_client.reactions_remove( - channel=env.slack_help_channel, - name="white_check_mark", - timestamp=ticket.msgTs, - ) + try: + await env.slack_client.reactions_remove( + channel=env.slack_help_channel, + name="white_check_mark", + timestamp=ticket.msgTs, + ) + except SlackApiError as e: + logging.error( + f"Failed to remove check reaction from ticket with ts {ticket.msgTs}: {e.response['error']}" + ) await env.slack_client.reactions_add( channel=env.slack_help_channel, name="thinking_face",