fix(slack): improve rate limit error handling and logging #35588
+36
−11
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
SUMMARY
Fixes the issue where Slack API rate limit errors (HTTP 429) were being swallowed or masked by generic error messages in the
slack-sdk
library's retry handler. This change improves observability and reliability of Slack integrations by adding explicit error detection and detailed logging.Root Cause: The
RateLimitErrorRetryHandler
in the slack-sdk library can re-raise errors without proper context when certain conditions are met. When these errors bubble up to generic exception handlers, they get logged as "Failed to send a request to Slack API server" instead of clearly indicating a rate limit issue.Changes:
get_channels()
ex.response
could be a string instead of response object usinghasattr()
checkImpact: Rate limit errors will now be clearly visible in monitoring systems like Datadog with actionable information (Retry-After values, retry counts), making it much easier to diagnose and respond to Slack API rate limiting issues.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A - Backend logging improvement
TESTING INSTRUCTIONS
pytest tests/unit_tests/utils/slack_test.py
pre-commit run --files superset/utils/slack.py
ADDITIONAL INFORMATION