Skip to content

fix(web): apply retry handlers to files_upload_v2 file POST - #1941

Open
DSeaStar wants to merge 1 commit into
slackapi:mainfrom
DSeaStar:fix/files-upload-v2-retry-handlers
Open

fix(web): apply retry handlers to files_upload_v2 file POST#1941
DSeaStar wants to merge 1 commit into
slackapi:mainfrom
DSeaStar:fix/files-upload-v2-retry-handlers

Conversation

@DSeaStar

Copy link
Copy Markdown

Summary

files_upload_v2 has three steps. Steps 1 and 3 (files.getUploadURLExternal / files.completeUploadExternal) go through api_call() and therefore honor the client's retry handlers. Step 2 — the raw POST to the files.slack.com upload URL — called _upload_file_via_v2_url() directly, so transient HTTP errors (the reporter sees 2–6 HTTP 504s per day) escaped to the caller.

This change runs that POST through the same retry-handler loop used by api_call(). Existing handlers (including custom ones that retry 504) now apply. When no handler matches, the original HTTPError is still raised.

Fixes #1853

Testing

  • pytest tests/slack_sdk/web/test_web_client_file_upload_retry.py
    • 504 then 200 with a 5xx retry handler succeeds
    • 504 with no handlers still raises HTTPError
  • pytest tests/slack_sdk/web/test_web_client_http_retry.py tests/slack_sdk/web/test_web_client_http_retry_server_error.py tests/slack_sdk/http_retry/test_builtins.py (existing retry tests, still pass)

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've run the new unit tests and the existing WebClient retry tests after making the changes.

Note: I did not run the full ./scripts/run_validation.sh matrix locally. Async files_upload_v2 already used retry handlers; this PR only changes the sync path, as confirmed in #1853.

The getUploadURLExternal and completeUploadExternal steps already go
through api_call(), but the files.slack.com POST did not. Transient
errors such as HTTP 504 therefore escaped even when the client had
retry handlers configured.

Fixes slackapi#1853
@DSeaStar
DSeaStar requested a review from a team as a code owner August 14, 2026 17:21
@salesforce-cla

Copy link
Copy Markdown

Thanks for the contribution! Before we can merge this, we need @DSeaStar to sign the Salesforce Inc. Contributor License Agreement.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

files_upload_v2 should respect the retry handlers

1 participant