The Fix
In my case it didn't solve the issue even when it uses the latest request library I think it has to be fixed in poetry also but not sure...
Based on closed psf/requests issue #6441
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%.
44│ if requests.__build__ < 0x021000:
45│ gaecontrib = None
46│ else:
47│ try:
→ 48│ from requests.packages.urllib3.contrib import appengine as gaecontrib
49│ except ImportError:
50│ from urllib3.contrib import appengine as gaecontrib
51│
52│ PY3 = sys.version_info > (3, 0)
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Option A — Apply the official fix\nIn my case it didn't solve the issue even when it uses the latest request library I think it has to be fixed in poetry also but not sure...\nWhen NOT to use: Do not use if it changes public behavior or if the failure cannot be reproduced.\n\n
Why This Fix Works in Production
- Trigger: ERROR: Job failed: command terminated with exit code 1'
- Mechanism: In my case it didn't solve the issue even when it uses the latest request library I think it has to be fixed in poetry also but not sure...
- 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
- Dependency interaction matters here: urllib3 v2.0.
- Shows up under Python 3.9 in real deployments (not just unit tests).
- Surfaces as: ERROR: Job failed: command terminated with exit code 1'
Proof / Evidence
- GitHub issue: #6441
- Reproduced locally: No (not executed)
- Last verified: 2026-02-08
- Confidence: 0.60
- Did this fix it?: No (no upstream fix linked)
- Own content ratio: 0.78
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“> Requests 2.30.0 has been unyanked, I hope that this solves the issue at hand (beyond the fixes provided in upgraded dependencies as has been…”
“> You can work it around by defining the request dependency as follow in your pyproject.toml: > > requests = "^2.28.2, !=2.30.0" > > This…”
“Hi there, I have the exact same issue here.”
“Two comments above yours explains the problem: https://github.com/psf/requests/issues/6441#issuecomment-1534752003”
Failure Signature (Search String)
- ERROR: Job failed: command terminated with exit code 1'
Error Message
Stack trace
Error Message
-------------
ERROR: Job failed: command terminated with exit code 1'
Minimal Reproduction
44│ if requests.__build__ < 0x021000:
45│ gaecontrib = None
46│ else:
47│ try:
→ 48│ from requests.packages.urllib3.contrib import appengine as gaecontrib
49│ except ImportError:
50│ from urllib3.contrib import appengine as gaecontrib
51│
52│ PY3 = sys.version_info > (3, 0)
Environment
- Python: 3.9
- urllib3: 2.0
Fix Options (Details)
Option A — Apply the official fix
In my case it didn't solve the issue even when it uses the latest request library I think it has to be fixed in poetry also but not sure...
Option D — Guard side-effects with OnceOnly Guardrail for side-effects
Mitigate duplicate external side-effects under retries/timeouts/agent loops by gating the operation before calling external systems.
- Place OnceOnly between your code/agent and real side-effects (Stripe, emails, CRM, APIs).
- Use a stable key per side-effect (e.g., customer_id + action + idempotency_key).
- Fail-safe: configure fail-open vs fail-closed based on blast radius and spend risk.
Show example snippet (optional)
from onceonly import OnceOnly
import os
once = OnceOnly(api_key=os.environ["ONCEONLY_API_KEY"], fail_open=True)
# Stable idempotency key per real side-effect.
# Use a request id / job id / webhook delivery id / Stripe event id, etc.
event_id = "evt_..." # replace
key = f"stripe:webhook:{event_id}"
res = once.check_lock(key=key, ttl=3600)
if res.duplicate:
return {"status": "already_processed"}
# Safe to execute the side-effect exactly once.
handle_event(event_id)
Fix reference: https://github.com/psf/requests/issues/6441
When NOT to Use This Fix
- Do not use if it changes public behavior or if the failure cannot be reproduced.
- Do not use this to hide logic bugs or data corruption. Use it to block duplicate external side-effects and enforce tool permissions/spend caps.
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
- Add a TLS smoke test that performs a real handshake in CI (include CA bundle validation and hostname checks).
- Alert on handshake failures by error string and endpoint to catch cert/CA changes quickly.
- Track RSS + object counts after deployments; alert on monotonic growth and GC pressure.
- Add a long-running test that repeats the failing call path and asserts stable memory.
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.