Skip to content

Commit

Permalink
Skip retries for defined SlackAPIErrorCode (#4913)
Browse files Browse the repository at this point in the history
Does not retry for any item in the SlackAPIErrorCode enum
  • Loading branch information
jschroth authored Jul 3, 2024
1 parent 990aea6 commit ec1847c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/dispatch/plugins/dispatch_slack/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ def should_retry(exception: Exception) -> bool:
"""
match exception:
case SlackApiError():
# Don't retry for re-adding users in channel.
if exception.response["error"] in [SlackAPIErrorCode.USER_IN_CHANNEL, SlackAPIErrorCode.ALREADY_IN_CHANNEL]:
# Don't retry for exceptions we have defined.
if exception.response["error"] in [str(getattr(SlackAPIErrorCode, i)) for i in SlackAPIErrorCode.__members__]:
return False
# Retry if it's not a fatal error
return exception.response["error"] != SlackAPIErrorCode.FATAL_ERROR
# retry all others
return True
case TimeoutError() | Timeout():
# Always retry on timeout errors
return True
Expand Down

0 comments on commit ec1847c

Please sign in to comment.