Skip to content

fix(web): use the request body for has_json and read async upload data - #2037

Merged
WilliamBergamin merged 1 commit into
mainfrom
fix/web-has-json-and-async-upload-body
Nov 13, 2026
Merged

WilliamBergamin merged 1 commit into
mainfrom
fix/web-has-json-and-async-upload-body

Conversation

@WilliamBergamin

Copy link
Copy Markdown
Contributor

Summary

This pull request fixes two one-token bugs in the web clients' request and upload paths.

  • BaseClient and LegacyBaseClient passed has_json=json is not None to _build_urllib_request_headers. That tests the stdlib json module, so it was always True. Requests with a body were unaffected, because _perform_urllib_http_request resets Content-Type, but bodyless calls such as api_test() went out as application/json. Now it checks json_body, the same way _build_req_args already does.
  • AsyncBaseClient._upload_file read result.get("body"), but _request_with_session returns data. A failed async files_upload_v2 upload raised SlackRequestError with body: None and lost the server's error text. The sync client already reads the right key.

Testing

The new tests fail on main and pass on this branch:

  • Sync and legacy: a bodyless api_test() sends application/x-www-form-urlencoded.
  • Async: _upload_file returns the response body when the upload fails.

A JSON-body call still sends application/json;charset=utf-8. That test guards against regressions and passes both before and after.

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

🤖 Generated with Claude Code

The urllib clients passed `json is not None` (the stdlib module) as
has_json, so bodyless requests went out with a JSON Content-Type. The
async `_upload_file` read a "body" key that `_request_with_session`
never returns, so failed `files_upload_v2` uploads reported `body: None`.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
@WilliamBergamin WilliamBergamin self-assigned this Nov 13, 2026
@WilliamBergamin WilliamBergamin added bug M-T: A confirmed bug report. Issues are confirmed when the reproduction steps are documented semver:patch web-client labels Nov 13, 2026
@codecov

codecov Bot commented Nov 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.43%. Comparing base (b6c005a) to head (528d39a).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2037      +/-   ##
==========================================
+ Coverage   84.36%   84.43%   +0.06%     
==========================================
  Files         118      118              
  Lines       14034    14034              
==========================================
+ Hits        11840    11849       +9     
+ Misses       2194     2185       -9     

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

@WilliamBergamin
WilliamBergamin marked this pull request as ready for review November 13, 2026 19:03
@WilliamBergamin
WilliamBergamin requested a review from a team as a code owner November 13, 2026 19:03
@zimeg zimeg added this to the 3.47.1 milestone Nov 13, 2026

@zimeg zimeg 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.

🐍 @WilliamBergamin LGTM! Great catch on the json module shadowing, and nice to see the sync, legacy and async clients all fixed together 🧪

@WilliamBergamin
WilliamBergamin merged commit 3df2179 into main Nov 13, 2026
19 checks passed
@WilliamBergamin
WilliamBergamin deleted the fix/web-has-json-and-async-upload-body branch November 13, 2026 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants