The Fix
pip install pydantic==1.10.19
Based on closed pydantic/pydantic issue #10600 · PR/commit linked
Production note: Watch p95/p99 latency and retry volume; timeouts can turn into retry storms and duplicate side-effects.
@@ -722,7 +722,7 @@ def _build_pretty_email_regex() -> re.Pattern[str]:
unquoted_name_group = rf'((?:{name_chars}+\s+)*{name_chars}+)'
quoted_name_group = r'"((?:[^"]|\")+)"'
- email_group = r'<\s*(.+)\s*>'
+ email_group = r'<(.+)>'
return re.compile(rf'\s*(?:{unquoted_name_group}|{quoted_name_group})?\s*{email_group}\s*')
import sys
from pydantic import BaseModel, EmailStr, ValidationError
import time
class TestModel(BaseModel):
email: EmailStr
def main(max_ind: int):
for ind in range(1, max_ind):
begin_at = time.time()
try:
TestModel.parse_obj({"email": "<" + " " * ind})
except ValidationError:
pass
delta = time.time() - begin_at
print(
f"{ind} takes: {delta:0.6f}, delta**1/3 / ind is {delta**(1/3) / ind:0.6f}"
)
return
if __name__ == "__main__":
main(int(sys.argv[1]))
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==1.10.19\nWhen NOT to use: This fix should not be applied if backward compatibility with previous regex behavior is required.\n\n
Why This Fix Works in Production
- Trigger: I found that current pydantic-level regexp is not optimal and may cause unexpected slowdowns on some edgecases. Email strings like `< ` (+many spaces).
- Mechanism: The email regex pattern was inefficient, causing slowdowns on certain edge cases
- Why the fix works: Improves email regex performance on edge cases by modifying the regex pattern to eliminate unnecessary whitespace handling. (first fixed release: 1.10.19).
- If left unfixed, tail latency can spike under load and surface as timeouts/retries (amplifying incident impact).
Why This Breaks in Prod
- Shows up under Python 3.12 in real deployments (not just unit tests).
- The email regex pattern was inefficient, causing slowdowns on certain edge cases
- Production symptom (often without a traceback): I found that current pydantic-level regexp is not optimal and may cause unexpected slowdowns on some edgecases. Email strings like `< ` (+many spaces).
Proof / Evidence
- GitHub issue: #10600
- Fix PR: https://github.com/pydantic/pydantic/pull/10601
- First fixed release: 1.10.19
- Reproduced locally: No (not executed)
- Last verified: 2026-02-09
- Confidence: 0.85
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.53
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 found that current pydantic-level regexp is not optimal and may cause unexpected slowdowns on some edgecases. Email strings like < (+many spaces). POC below sho”
Failure Signature (Search String)
- I found that current pydantic-level regexp is not optimal and may cause unexpected slowdowns on some edgecases. Email strings like `< ` (+many spaces).
- POC below shows it. You can run it with command like `/usr/bin/time python pydantic-poc.py 500`.
Copy-friendly signature
Failure Signature
-----------------
I found that current pydantic-level regexp is not optimal and may cause unexpected slowdowns on some edgecases. Email strings like `< ` (+many spaces).
POC below shows it. You can run it with command like `/usr/bin/time python pydantic-poc.py 500`.
Error Message
Signature-only (no traceback captured)
Error Message
-------------
I found that current pydantic-level regexp is not optimal and may cause unexpected slowdowns on some edgecases. Email strings like `< ` (+many spaces).
POC below shows it. You can run it with command like `/usr/bin/time python pydantic-poc.py 500`.
Minimal Reproduction
import sys
from pydantic import BaseModel, EmailStr, ValidationError
import time
class TestModel(BaseModel):
email: EmailStr
def main(max_ind: int):
for ind in range(1, max_ind):
begin_at = time.time()
try:
TestModel.parse_obj({"email": "<" + " " * ind})
except ValidationError:
pass
delta = time.time() - begin_at
print(
f"{ind} takes: {delta:0.6f}, delta**1/3 / ind is {delta**(1/3) / ind:0.6f}"
)
return
if __name__ == "__main__":
main(int(sys.argv[1]))
Environment
- Python: 3.12
- Pydantic: 2
What Broke
Email parsing resulted in significant slowdowns for specific input formats.
Why It Broke
The email regex pattern was inefficient, causing slowdowns on certain edge cases
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install pydantic==1.10.19
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/10601
First fixed release: 1.10.19
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix should not be applied if backward compatibility with previous regex behavior is required.
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 |
|---|---|
| 1.10.19 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.