Jump to solution
Verify

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%.

Jump to Verify Open PR/Commit
@@ -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) +
repro.py
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
verify
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
fix.md
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).
Production impact:
  • 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

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?”
@anton-daneyko-ultramarin · 2024-11-23 · source
“Added the PR https://github.com/pydantic/pydantic/pull/10956”
@vivekkeshore · 2024-11-23 · source

Failure Signature (Search String)

  • import pydantic

Error Message

Stack trace
error.txt
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

repro.py
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

When NOT to use: Do not use this fix if hashability is not required for your application.

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.

Get updates

We publish verified fixes weekly. No spam.

Subscribe

When NOT to Use This Fix

  • Do not use this fix if hashability is not required for your application.

Verify Fix

verify
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

VersionStatus
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.