The Fix
pip install requests==2.27.0
Based on closed psf/requests issue #3102 · PR/commit linked
Production note: Most teams hit this during upgrades or environment changes. Roll out with a canary and smoke critical endpoints (health, OpenAPI/docs) before 100%.
@@ -557,7 +557,7 @@ def send(self, request, **kwargs):
# It's possible that users might accidentally send a Request object.
# Guard against that specific failure case.
- if not isinstance(request, PreparedRequest):
+ if isinstance(request, Request):
raise ValueError('You can only send PreparedRequests.')
Traceback (most recent call last):
File "deploy.py", line 43, in <module>
main(args.realm)
File "deploy.py", line 29, in main
results = [client.update_function_code(FunctionName=arn, ZipFile=data) for arn in arns]
File "/home/ubuntu/webhooks/src/botocore/botocore/client.py", line 236, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/home/ubuntu/webhooks/src/botocore/botocore/client.py", line 489, in _make_api_call
operation_model, request_dict)
File "/home/ubuntu/webhooks/src/botocore/endpoint.py", line 117, in make_request
return self._send_request(request_dict, operation_model)
File "/home/ubuntu/webhooks/src/botocore/endpoint.py", line 146, in _send_request
success_response, exception):
File "/home/ubuntu/webhooks/src/botocore/endpoint.py", line 219, in _needs_retry
caught_exception=caught_exception)
File "/home/ubuntu/webhooks/src/botocore/botocore/hooks.py", line 226, in emit
return self._emit(event_name, kwargs)
File "/home/ubuntu/webhooks/src/botocore/botocore/hooks.py", line 209, in _emit
response = handler(**kwargs)
File "/home/ubuntu/webhooks/src/botocore/botocore/retryhandler.py", line 183, in __call__
if self._checker(attempts, response, caught_exception):
File "/home/ubuntu/webhooks/src/botocore/botocore/retryhandler.py", line 250, in __call__
caught_exception)
File "/home/ubuntu/webhooks/src/botocore/botocore/retryhandler.py", line 265, in _should_retry
return self._checker(attempt_number, response, caught_exception)
File "/home/ubuntu/webhooks/src/botocore/botocore/retryhandler.py", line 313, in __call__
caught_exception)
File "/home/ubuntu/webhooks/src/botocore/botocore/retryhandler.py", line 222, in __call__
return self._check_caught_exception(attempt_number, caught_exception)
File "/home/ubuntu/webhooks/src/botocore/botocore/retryhandler.py", line 355, in _check_caught_exception
raise caught_exception
ValueError: You can only send PreparedRequests.
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Option A — Upgrade to fixed release\npip install requests==2.27.0\nWhen NOT to use: This fix is not safe if the library versions are not properly managed to avoid namespace conflicts.\n\n
Why This Fix Works in Production
- Trigger: main(args.realm)
- Mechanism: The check for PreparedRequest instances failed due to namespace conflicts from multiple library versions
- Why the fix works: Flips the conditional check in session.send() to allow sending PreparedRequests created from different instances of the Requests library. (first fixed release: 2.27.0).
- If left unfixed, the same config can fail only in production (env differences), causing startup failures or partial feature outages.
Why This Breaks in Prod
- The check for PreparedRequest instances failed due to namespace conflicts from multiple library versions
- Surfaces as: Traceback (most recent call last):
Proof / Evidence
- GitHub issue: #3102
- Fix PR: https://github.com/psf/requests/pull/3108
- First fixed release: 2.27.0
- Reproduced locally: No (not executed)
- Last verified: 2026-02-07
- Confidence: 0.85
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.27
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“That's a good question”
Failure Signature (Search String)
- main(args.realm)
Error Message
Stack trace
Error Message
-------------
Traceback (most recent call last):
File "deploy.py", line 43, in <module>
main(args.realm)
File "deploy.py", line 29, in main
results = [client.update_function_code(FunctionName=arn, ZipFile=data) for arn in arns]
File "/home/ubuntu/webhooks/src/botocore/botocore/client.py", line 236, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/home/ubuntu/webhooks/src/botocore/botocore/client.py", line 489, in _make_api_call
operation_model, request_dict)
File "/home/ubuntu/webhooks/src/botocore/endpoint.py", line 117, in make_request
return self._send_request(request_dict, operation_model)
File "/home/ubuntu/webhooks/src/botocore/endpoint.py", line 146, in _send_request
success_response, exception):
File "/home/ubuntu/webhooks/src/botocore/endpoint.py", line 219, in _needs_retry
caught_exception=caught_exception)
File "/home/ubuntu/webhooks/src/botocore/botocore/hooks.py", line 226, in emit
return self._emit(event_name, kwargs)
File "/home/ubuntu/webhooks/src/botocore/botocore/hooks.py", line 209, in _emit
response = handler(**kwargs)
File "/home/ubuntu/webhooks/src/botocore/botocore/retryhandler.py", line 183, in __call__
if self._checker(attempts, response, caught_exception):
File "/home/ubuntu/webhooks/src/botocore/botocore/retryhandler.py", line 250, in __call__
caught_exception)
File "/home/ubu
... (truncated) ...
Minimal Reproduction
Traceback (most recent call last):
File "deploy.py", line 43, in <module>
main(args.realm)
File "deploy.py", line 29, in main
results = [client.update_function_code(FunctionName=arn, ZipFile=data) for arn in arns]
File "/home/ubuntu/webhooks/src/botocore/botocore/client.py", line 236, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/home/ubuntu/webhooks/src/botocore/botocore/client.py", line 489, in _make_api_call
operation_model, request_dict)
File "/home/ubuntu/webhooks/src/botocore/endpoint.py", line 117, in make_request
return self._send_request(request_dict, operation_model)
File "/home/ubuntu/webhooks/src/botocore/endpoint.py", line 146, in _send_request
success_response, exception):
File "/home/ubuntu/webhooks/src/botocore/endpoint.py", line 219, in _needs_retry
caught_exception=caught_exception)
File "/home/ubuntu/webhooks/src/botocore/botocore/hooks.py", line 226, in emit
return self._emit(event_name, kwargs)
File "/home/ubuntu/webhooks/src/botocore/botocore/hooks.py", line 209, in _emit
response = handler(**kwargs)
File "/home/ubuntu/webhooks/src/botocore/botocore/retryhandler.py", line 183, in __call__
if self._checker(attempts, response, caught_exception):
File "/home/ubuntu/webhooks/src/botocore/botocore/retryhandler.py", line 250, in __call__
caught_exception)
File "/home/ubuntu/webhooks/src/botocore/botocore/retryhandler.py", line 265, in _should_retry
return self._checker(attempt_number, response, caught_exception)
File "/home/ubuntu/webhooks/src/botocore/botocore/retryhandler.py", line 313, in __call__
caught_exception)
File "/home/ubuntu/webhooks/src/botocore/botocore/retryhandler.py", line 222, in __call__
return self._check_caught_exception(attempt_number, caught_exception)
File "/home/ubuntu/webhooks/src/botocore/botocore/retryhandler.py", line 355, in _check_caught_exception
raise caught_exception
ValueError: You can only send PreparedRequests.
What Broke
Deployments to AWS failed with ValueError due to incompatible PreparedRequest instances.
Why It Broke
The check for PreparedRequest instances failed due to namespace conflicts from multiple library versions
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install requests==2.27.0
Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.
Fix reference: https://github.com/psf/requests/pull/3108
First fixed release: 2.27.0
Last verified: 2026-02-07. Validate in your environment.
When NOT to Use This Fix
- This fix is not safe if the library versions are not properly managed to avoid namespace conflicts.
Verify Fix
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Did This Fix Work in Your Case?
Quick signal helps us prioritize which fixes to verify and improve.
Prevention
- Capture the exact failing error string in logs and tests so you can reproduce via a minimal script.
- Pin production dependencies and upgrade only with a reproducible test that hits the failing path.
Version Compatibility Table
| Version | Status |
|---|---|
| 2.27.0 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.