Jump to solution
Details

The Fix

pip install urllib3==1.25.9

Based on closed urllib3/urllib3 issue #1766 · PR/commit linked

Production note: This tends to surface only under concurrency. Reproduce with load tests and watch for lock contention/cancellation paths.

Open PR/Commit
@@ -173,29 +173,8 @@ def test_client_no_intermediate(self): ca_certs=DEFAULT_CA, ) as https_pool: - try: + with pytest.raises((SSLError, ProtocolError)): https_pool.request("GET", "/certificate", retries=False)
fix.md
Option A — Upgrade to fixed release\npip install urllib3==1.25.9\nWhen NOT to use: This fix should not be used if the test requires specific exception handling for validation.\n\n

Why This Fix Works in Production

  • Trigger: ==================================================================== FAILURES =====================================================================
  • Mechanism: The test_client_no_intermediate test was relying on specific exception values, causing flakiness
  • Why the fix works: The test_client_no_intermediate test was modified to stop looking at exception values, improving its reliability. (first fixed release: 1.25.9).
Production impact:
  • If left unfixed, failures can be intermittent under concurrency (hard to reproduce; shows up as sporadic 5xx/timeouts).

Why This Breaks in Prod

  • Shows up under Python 2.7 in real deployments (not just unit tests).
  • The test_client_no_intermediate test was relying on specific exception values, causing flakiness
  • Surfaces as: ==================================================================== FAILURES =====================================================================

Proof / Evidence

  • GitHub issue: #1766
  • Fix PR: https://github.com/urllib3/urllib3/pull/1811
  • First fixed release: 1.25.9
  • Reproduced locally: No (not executed)
  • Last verified: 2026-02-09
  • Confidence: 0.95
  • Did this fix it?: Yes (upstream fix exists)
  • Own content ratio: 0.47

Discussion

High-signal excerpts from the issue thread (symptoms, repros, edge-cases).

“@hodbn Thanks for the follow-up! @mgorny Thanks for trying this again! This was fixed in https://github.com/urllib3/urllib3/pull/1811, sorry I had forgot about this issue. We can…”
@pquentin · 2020-05-25 · confirmation · source
“Can you point to a failing CI build or describe your setup?”
@hodbn · 2020-05-24 · source
“@mgorny Thanks for tracking this, let us know if you have more issues with this test. Thanks for maintaining urllib3 dists on Gentoo :)”
@sethmlarson · 2020-05-24 · source
“That would be a good question back in December”
@mgorny · 2020-05-24 · source

Failure Signature (Search String)

  • ==================================================================== FAILURES =====================================================================

Error Message

Stack trace
error.txt
Error Message ------------- ==================================================================== FAILURES ===================================================================== Exception in thread Thread-120: Traceback (most recent call last): File "/usr/lib64/python2.7/threading.py", line 801, in __bootstrap_inner self.run() File "/tmp/urllib3/dummyserver/server.py", line 145, in run self.server = self._start_server() File "/tmp/urllib3/dummyserver/server.py", line 141, in _start_server self.socket_handler(sock) File "/tmp/urllib3/test/with_dummyserver/test_socketlevel.py", line 1331, in socket_handler ca_certs=DEFAULT_CA, File "/usr/lib64/python2.7/ssl.py", line 931, in wrap_socket ciphers=ciphers) File "/usr/lib64/python2.7/ssl.py", line 599, in __init__ self.do_handshake() File "/usr/lib64/python2.7/ssl.py", line 828, in do_handshake self._sslobj.do_handshake() error: [Errno 0] Error Exception in thread Thread-119: Traceback (most recent call last): File "/usr/lib64/python2.7/threading.py", line 801, in __bootstrap_inner self.run() File "/tmp/urllib3/dummyserver/server.py", line 145, in run self.server = self._start_server() File "/tmp/urllib3/dummyserver/server.py", line 141, in _start_server self.socket_handler(sock) File "/tmp/urllib3/test/with_dummyserver/test_socketlevel.py", line 1331, in socket_handler ca_certs=DEFAULT_CA, File ... (truncated) ...

Environment

  • Python: 2.7

What Broke

The test intermittently failed, leading to unreliable CI results.

Why It Broke

The test_client_no_intermediate test was relying on specific exception values, causing flakiness

Fix Options (Details)

Option A — Upgrade to fixed release Safe default (recommended)

pip install urllib3==1.25.9

When NOT to use: This fix should not be used if the test requires specific exception handling for validation.

Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.

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)
onceonly.py
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)

See OnceOnly SDK

When NOT to use: 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.

Fix reference: https://github.com/urllib3/urllib3/pull/1811

First fixed release: 1.25.9

Last verified: 2026-02-09. Validate in your environment.

Get updates

We publish verified fixes weekly. No spam.

Subscribe

When NOT to Use This Fix

  • This fix should not be used if the test requires specific exception handling for validation.
  • 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.

Did This Fix Work in Your Case?

Quick signal helps us prioritize which fixes to verify and improve.

Prevention

  • Add a CI check that diffs key outputs after upgrades (OpenAPI schema snapshots, JSON payload shapes, CLI output).
  • Upgrade behind a canary and run integration tests against the canary before 100% rollout.
  • Add a stress test that runs high-concurrency workloads and fails on thread dumps / blocked locks.
  • Enable watchdog dumps in prod (faulthandler, thread dump endpoint) to capture deadlocks quickly.

Version Compatibility Table

VersionStatus
1.25.9 Fixed

Related Issues

No related fixes found.

Sources

We don’t republish the full GitHub discussion text. Use the links above for context.