Repository navigation
fix(web): use the request body for has_json and read async upload data - #2037
Merged
Merged
Conversation
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>
Codecov Report✅ All modified and coverable lines are covered by tests. 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. |
zimeg
approved these changes
Nov 13, 2026
zimeg
left a comment
Member
There was a problem hiding this comment.
🐍 @WilliamBergamin LGTM! Great catch on the json module shadowing, and nice to see the sync, legacy and async clients all fixed together 🧪
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This pull request fixes two one-token bugs in the web clients' request and upload paths.
BaseClientandLegacyBaseClientpassedhas_json=json is not Noneto_build_urllib_request_headers. That tests the stdlibjsonmodule, so it was alwaysTrue. Requests with a body were unaffected, because_perform_urllib_http_requestresets Content-Type, but bodyless calls such asapi_test()went out asapplication/json. Now it checksjson_body, the same way_build_req_argsalready does.AsyncBaseClient._upload_filereadresult.get("body"), but_request_with_sessionreturnsdata. A failed asyncfiles_upload_v2upload raisedSlackRequestErrorwithbody: Noneand lost the server's error text. The sync client already reads the right key.Testing
The new tests fail on
mainand pass on this branch:api_test()sendsapplication/x-www-form-urlencoded._upload_filereturns 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
/docs(Documents)/tutorial(PythOnBoardingBot tutorial)tests/integration_tests(Automated tests for this library)Requirements
🤖 Generated with Claude Code