fix(slack): surface retryable + Retry-After on send() rate-limit errors (#46762)

Slack's send() caught all exceptions and returned a bare
SendResult(success=False) — never setting retryable=True or extracting
the server's Retry-After header.  When Slack returned a 429 rate-limit
error, the base _send_with_retry() layer saw retryable=False and did
not retry, silently dropping remaining message chunks.

Reuse the existing _is_retryable_upload_error() helper (which already
detects 429, 500+, and connection-type errors) to set retryable=True,
and extract the Retry-After header from the SlackApiError response
when present so the base retry layer honors Slack's backoff schedule
instead of its own default.

Sibling of the Telegram FloodWait fix (PR #46762 / commit 404b06ac4)
which added the SendResult.retry_after plumbing to the base layer.

Adds five regression tests covering 429 with/without Retry-After,
500 server errors, 403 non-retryable errors, and connection errors.
This commit is contained in:
srojk34 2026-06-25 12:24:28 +03:00 committed by Teknium
parent f8aef2e4e0
commit 5243fcafa1
2 changed files with 169 additions and 1 deletions

View file

@ -1914,7 +1914,23 @@ class SlackAdapter(BasePlatformAdapter):
if thread_ts:
await self.stop_typing(chat_id, metadata=metadata)
logger.error("[Slack] Send error: %s", e, exc_info=True)
return SendResult(success=False, error=str(e))
_retryable = self._is_retryable_upload_error(e)
_retry_after = None
if _retryable:
_resp = getattr(e, "response", None)
if _resp is not None:
try:
_ra = getattr(_resp, "headers", {}).get("Retry-After")
if _ra is not None:
_retry_after = float(_ra)
except (TypeError, ValueError, AttributeError):
pass
return SendResult(
success=False,
error=str(e),
retryable=_retryable,
retry_after=_retry_after,
)
async def send_private_notice(
self,