Skip to content

fix(web, audit_logs, scim, webhook): pass the status error to async retry handlers - #2080

Open
WilliamBergamin wants to merge 3 commits into
mainfrom
fix/async-retry-status-error
Open

WilliamBergamin wants to merge 3 commits into
mainfrom
fix/async-retry-status-error

Conversation

@WilliamBergamin

@WilliamBergamin WilliamBergamin commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This pull request passes an error to async retry handlers on an HTTP error status, as the sync clients already do.

  • On a 4xx/5xx the sync clients call can_retry / prepare_for_next_attempt with the urllib HTTPError, but the async WebClient, AuditLogsClient, SCIMClient and WebhookClient passed no error, so handlers saw None. Left over from fix(audit_logs, scim, webhook): retry async calls on any error status #2061.
  • They now pass the aiohttp.ClientResponseError that res.raise_for_status() raises, the way urllib raises HTTPError for the sync clients. WebClient still passes None for responses under 400.
  • AsyncConnectionErrorRetryHandler now skips ClientResponseError, mirroring the sync handler's HTTPError check, so error_types=[aiohttp.ClientError] does not start retrying every 4xx.
  • Behavior change: custom async handlers now receive a non-None error on error statuses. A handler that retries on any non-None error will now retry status errors, as it already does on sync. Worth a line in the release notes.

Testing

Each async *_http_retry suite gets a test that hits the mock 500 endpoint and checks both handler methods receive a ClientResponseError with status == 500. They fail on main and pass here. tests/slack_sdk_async/http_retry/test_builtins.py checks the connection handler skips a status error even when error_types includes aiohttp.ClientError.

Category

  • slack_sdk.web.WebClient (sync/async) (Web API client)
  • slack_sdk.webhook.WebhookClient (sync/async) (Incoming Webhook, response_url sender)
  • slack_sdk.socket_mode (Socket Mode client)
  • slack_sdk.signature (Request Signature Verifier)
  • slack_sdk.oauth (OAuth Flow Utilities)
  • slack_sdk.models (UI component builders)
  • slack_sdk.scim (SCIM API client)
  • slack_sdk.audit_logs (Audit Logs API client)
  • slack_sdk.rtm_v2 (RTM client)
  • /docs (Documents)
  • /tutorial (PythOnBoardingBot tutorial)
  • tests/integration_tests (Automated tests for this library)

Requirements

  • I've read and understood the Contributing Guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I have signed the Salesforce CLA (required before your PR can be reviewed or merged).
  • I've run python3 -m venv .venv && source .venv/bin/activate && ./scripts/run_validation.sh after making the changes.

🤖 Generated with Claude Code

…etry handlers

On an error status the sync clients hand retry handlers the urllib
HTTPError, but the async clients passed no error at all. They now pass
an aiohttp ClientResponseError built from the response, and
AsyncConnectionErrorRetryHandler skips it the way the sync handler
skips HTTPError.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
@codecov

codecov Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.61538% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.73%. Comparing base (80f2f22) to head (788588d).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
slack_sdk/web/async_internal_utils.py 73.33% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2080      +/-   ##
==========================================
+ Coverage   84.69%   84.73%   +0.04%     
==========================================
  Files         118      118              
  Lines       14116    14131      +15     
==========================================
+ Hits        11955    11974      +19     
+ Misses       2161     2157       -4     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

WilliamBergamin and others added 2 commits November 23, 2026 13:24
Let aiohttp raise the ClientResponseError itself, the way urllib raises
HTTPError for the sync clients, instead of rebuilding it by hand.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
…r like sync

Drop the _status_error helper. Each async client now calls
res.raise_for_status() and runs its retry handlers in an
except aiohttp.ClientResponseError branch, mirroring the sync clients'
except HTTPError branch. WebClient keeps a separate handler loop for
successful responses, as the sync BaseClient does.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
@WilliamBergamin WilliamBergamin self-assigned this Nov 23, 2026
@WilliamBergamin WilliamBergamin added bug M-T: A confirmed bug report. Issues are confirmed when the reproduction steps are documented semver:patch area:async web-client scim-client audit-logs-client labels Nov 23, 2026
@WilliamBergamin
WilliamBergamin marked this pull request as ready for review November 23, 2026 21:59
@WilliamBergamin
WilliamBergamin requested a review from a team as a code owner November 23, 2026 21:59
@WilliamBergamin WilliamBergamin added this to the 3.48.1 milestone Nov 23, 2026

@mwbrooks mwbrooks left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One blocking point: the new ClientResponseError skip in the connection handler also drops retries for proxy and redirect errors. Once it matches the sync check, this is an approve from me.

Comment on lines +40 to 41
if error is None or isinstance(error, ClientResponseError):
return False

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (blocking): This also skips ClientHttpProxyError and TooManyRedirects, which aiohttp raises before any response exists, so error_types=[aiohttp.ClientError] stops retrying proxy errors it retries today. Could we match the sync handler and only skip when there's a response?

Suggested change
if error is None or isinstance(error, ClientResponseError):
return False
if error is None:
return False
if isinstance(error, ClientResponseError) and response is not None:
return False # status 4xx/5xx

if logger.level <= logging.DEBUG:
logger.info(f"A retry handler found: {type(handler).__name__} for {http_verb} {api_url}")
await handler.prepare_for_next_attempt_async(
try:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (non-blocking): The two handler loops only differ by error=e, so we could start with error = None, assign it in the except, and keep one loop that passes error=error. One copy is easier to keep in step with the other three clients.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:async audit-logs-client bug M-T: A confirmed bug report. Issues are confirmed when the reproduction steps are documented scim-client semver:patch web-client

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants