The Fix
pip install pydantic==2.10.2
Based on closed pydantic/pydantic issue #10955 · 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%.
@@ -224,6 +224,9 @@ def __deepcopy__(self, memo: dict) -> Self:
return self.__class__ is other.__class__ and self._url == other._url
+ def __hash__(self) -> int:
+ return hash(self._url)
+
pydantic version: 2.10.1
pydantic-core version: 2.27.1
pydantic-core build: profile=release pgo=false
install path: /Users/ant/miniforge3/envs/apa-proxy/lib/python3.12/site-packages/pydantic
python version: 3.12.7 | packaged by conda-forge | (main, Oct 4 2024, 15:57:01) [Clang 17.0.6 ]
platform: macOS-15.1-arm64-arm-64bit
related packages: pydantic-settings-2.6.1 fastapi-0.115.5 typing_extensions-4.12.2
commit: unknown
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Option A — Upgrade to fixed release\npip install pydantic==2.10.2\nWhen NOT to use: Do not use this fix if hashability is not required for your application.\n\n
Why This Fix Works in Production
- Trigger: import pydantic
- Mechanism: Added hashing support for AnyHttpUrl to make it hashable, resolving issue #10955.
- Why the fix works: Added hashing support for AnyHttpUrl to make it hashable, resolving issue #10955. (first fixed release: 2.10.2).
- 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
- Shows up under Python 3.12 in real deployments (not just unit tests).
- Surfaces as: import pydantic
Proof / Evidence
- GitHub issue: #10955
- Fix PR: https://github.com/pydantic/pydantic/pull/10975
- First fixed release: 2.10.2
- Reproduced locally: No (not executed)
- Last verified: 2026-02-09
- Confidence: 0.75
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.48
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“Could it be https://github.com/pydantic/pydantic/pull/10662 made it unhashable?”
“Added the PR https://github.com/pydantic/pydantic/pull/10956”
Failure Signature (Search String)
- import pydantic
Error Message
Stack trace
Error Message
-------------
import pydantic
{pydantic.AnyHttpUrl(url="http://hi.ho/")}
Traceback (most recent call last):
File "<input>", line 1, in <module>
TypeError: unhashable type: 'AnyHttpUrl'
Minimal Reproduction
pydantic version: 2.10.1
pydantic-core version: 2.27.1
pydantic-core build: profile=release pgo=false
install path: /Users/ant/miniforge3/envs/apa-proxy/lib/python3.12/site-packages/pydantic
python version: 3.12.7 | packaged by conda-forge | (main, Oct 4 2024, 15:57:01) [Clang 17.0.6 ]
platform: macOS-15.1-arm64-arm-64bit
related packages: pydantic-settings-2.6.1 fastapi-0.115.5 typing_extensions-4.12.2
commit: unknown
Environment
- Python: 3.12
- Pydantic: 2
What Broke
Users experienced TypeError when attempting to use AnyHttpUrl in sets or as dictionary keys.
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install pydantic==2.10.2
Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.
Fix reference: https://github.com/pydantic/pydantic/pull/10975
First fixed release: 2.10.2
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- Do not use this fix if hashability is not required for your application.
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 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.
Version Compatibility Table
| Version | Status |
|---|---|
| 2.10.2 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.