Fix: Pin urllib3<2 to resolve IPv6 Zone ID ValueError #7111
+1
−1
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 PR restricts the urllib3 dependency to versions <2 to resolve a regression in IPv6 Zone ID parsing. urllib3 v2.0 introduced stricter URL validation that causes requests to raise a ValueError when processing link-local IPv6 addresses with Zone IDs (e.g., fe80::...%eth0).
The Problem
When using urllib3 v2.x (default in recent installs), passing an IPv6 address with a Zone ID results in a ValueError during the validation phase, preventing the request from reaching the socket layer.
Reproduction:
import requests
Raises ValueError on urllib3 v2.x
requests.get('http://[fe80::be0f:a7ff:fe00:2929%25eth0]/')
Error:
ValueError: 'fe80::be0f:a7ff:fe00:2929' does not appear to be an IPv4 or IPv6 address
The Solution
Updated setup.py to pin urllib3>=1.21.1,<2. This reverts to the stable v1.26.x behavior, which is permissive of Zone IDs and correctly passes them to the underlying OS socket.
Verification
Reproduction Script: Confirmed that the ValueError is no longer raised and the request attempts a network connection.
Test Suite: Ran pytest tests locally.
Result: 595 passed, 15 skipped (No regressions found).
Related Issues
Fixes #6808 (Double-digit link-local IPv6 zone id raises ValueError)