Skip to content

Commit

Permalink
Adds Slack error code skip retry (#4912)
Browse files Browse the repository at this point in the history
  • Loading branch information
whitdog47 authored Jul 3, 2024
1 parent 0bcb2be commit 990aea6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/dispatch/plugins/dispatch_slack/incident/interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,10 @@ def handle_after_hours_message(
participant = participant_service.get_by_incident_id_and_email(
db_session=db_session, incident_id=context["subject"].id, email=user.email
)
# handle no participant found
if not participant:
return

# get their timezone from slack
try:
owner_tz = (dispatch_slack_service.get_user_info_by_email(client, email=owner_email))["tz"]
Expand Down
2 changes: 1 addition & 1 deletion src/dispatch/plugins/dispatch_slack/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def should_retry(exception: Exception) -> bool:
match exception:
case SlackApiError():
# Don't retry for re-adding users in channel.
if exception.response["error"] == SlackAPIErrorCode.USER_IN_CHANNEL:
if exception.response["error"] in [SlackAPIErrorCode.USER_IN_CHANNEL, SlackAPIErrorCode.ALREADY_IN_CHANNEL]:
return False
# Retry if it's not a fatal error
return exception.response["error"] != SlackAPIErrorCode.FATAL_ERROR
Expand Down

0 comments on commit 990aea6

Please sign in to comment.