eschutho commented on code in PR #35588:
URL: https://github.com/apache/superset/pull/35588#discussion_r2482656175
##########
superset/utils/slack.py:
##########
@@ -74,16 +75,40 @@ def get_channels() -> list[SlackChannelSchema]:
extra_params = {"types": ",".join(SlackChannelTypes)}
cursor = None
- while True:
- response = client.conversations_list(
- limit=999, cursor=cursor, exclude_archived=True, **extra_params
- )
- channels.extend(
- channel_schema.load(channel) for channel in
response.data["channels"]
- )
- cursor = response.data.get("response_metadata", {}).get("next_cursor")
- if not cursor:
- break
+ try:
+ while True:
+ try:
+ response = client.conversations_list(
+ limit=999, cursor=cursor, exclude_archived=True,
**extra_params
+ )
+ channels.extend(
+ channel_schema.load(channel)
+ for channel in response.data["channels"]
+ )
+ cursor = response.data.get("response_metadata",
{}).get("next_cursor")
+ if not cursor:
+ break
+ except SlackApiError as ex:
+ # Check if this is a rate limit error
+ if (
+ hasattr(ex.response, "status_code")
+ and ex.response.status_code == 429
+ ):
+ retry_after = ex.response.headers.get("Retry-After",
"unknown")
+ logger.error(
+ "Slack API rate limit exceeded (HTTP 429). "
+ "Retry-After: %s seconds. "
+ "This may indicate the retry handler failed or "
+ "exhausted retries (max 4). Error: %s",
+ retry_after,
+ ex,
+ )
+ else:
+ logger.error("Slack API error: %s", ex)
+ raise
+ except Exception:
+ logger.exception("Unexpected error fetching Slack channels")
+ raise
Review Comment:
I'd suggest the same here- raise a Superset error.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]