Jump to solution
Verify

The Fix

pip install pydantic==2.9.2

Based on closed pydantic/pydantic issue #10376 · 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
@@ -177,6 +177,7 @@ 'SecretStr', 'SecretBytes', + 'SocketPath', 'StrictBool', 'StrictBytes',
repro.py
def test_pydantic_socket_validation(): from pathlib import Path from pydantic import BaseModel, FilePath import socket class Reproduction(BaseModel): host: FilePath # clean up after ourselves socket_path = Path("/tmp")/"tmp_socket" socket_path.unlink(missing_ok=True) # create a socket sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) sock.bind("/tmp/tmp_socket") # create the real files for comparison real_file = Path("/tmp") / "foo.txt" real_file.unlink(missing_ok=True) # clean up after ourselves real_file.touch() link_to_real_file = Path("/tmp") / "foo.lnk.txt" link_to_real_file.unlink(missing_ok=True) # clean up after ourselves link_to_real_file.symlink_to(real_file) # assert real path to real file works Reproduction(host="/tmp/foo.txt") # assert symlinked path to real file works Reproduction(host="/tmp/foo.lnk.txt") # assert real path to socket works Reproduction(host="/tmp/tmp_socket") # explodes
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.9.2\nWhen NOT to use: This fix is not applicable for non-Linux systems where socket validation is not supported.\n\n

Why This Fix Works in Production

  • Trigger: Reproduction(host="/tmp/tmp_socket") # explodes
  • Mechanism: Added a new `SocketPath` type to allow validation of Unix domain sockets in Pydantic, addressing issue #10376.
  • Why the fix works: Added a new `SocketPath` type to allow validation of Unix domain sockets in Pydantic, addressing issue #10376. (first fixed release: 2.9.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: Reproduction(host="/tmp/tmp_socket") # explodes

Proof / Evidence

Discussion

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

“### Initial Checks - [X] I confirm that I'm using Pydantic V2 ### Description I want to pass a file path to an existing unix domain socket to a pydantic class and have it validate that the path exists. from linux's perspective, its the same”
Issue thread · issue description · source

Failure Signature (Search String)

  • Reproduction(host="/tmp/tmp_socket") # explodes

Error Message

Stack trace
error.txt
Error Message ------------- Reproduction(host="/tmp/tmp_socket") # explodes E pydantic_core._pydantic_core.ValidationError: 1 validation error for Reproduction E host E Path does not point to a file [type=path_not_file, input_value='/tmp/tmp_socket', input_type=str]

Minimal Reproduction

repro.py
def test_pydantic_socket_validation(): from pathlib import Path from pydantic import BaseModel, FilePath import socket class Reproduction(BaseModel): host: FilePath # clean up after ourselves socket_path = Path("/tmp")/"tmp_socket" socket_path.unlink(missing_ok=True) # create a socket sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) sock.bind("/tmp/tmp_socket") # create the real files for comparison real_file = Path("/tmp") / "foo.txt" real_file.unlink(missing_ok=True) # clean up after ourselves real_file.touch() link_to_real_file = Path("/tmp") / "foo.lnk.txt" link_to_real_file.unlink(missing_ok=True) # clean up after ourselves link_to_real_file.symlink_to(real_file) # assert real path to real file works Reproduction(host="/tmp/foo.txt") # assert symlinked path to real file works Reproduction(host="/tmp/foo.lnk.txt") # assert real path to socket works Reproduction(host="/tmp/tmp_socket") # explodes

Environment

  • Python: 3.12
  • Pydantic: 2

What Broke

Validation errors occur when attempting to validate Unix domain sockets as file paths.

Fix Options (Details)

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

pip install pydantic==2.9.2

When NOT to use: This fix is not applicable for non-Linux systems where socket validation is not supported.

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/10378

First fixed release: 2.9.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

  • This fix is not applicable for non-Linux systems where socket validation is not supported.

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.9.2 Fixed

Related Issues

No related fixes found.

Sources

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