The Fix
pip install pydantic==1.10.19
Based on closed pydantic/pydantic issue #9251 · 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%.
@@ -2477,9 +2477,11 @@ def __get_pydantic_json_schema__(
def __get_pydantic_core_schema__(self, source: type[Any], handler: GetCoreSchemaHandler) -> core_schema.CoreSchema:
+ schema = handler(source)
+ _check_annotated_type(schema['type'], 'bytes', self.__class__.__name__)
return core_schema.with_info_after_validator_function(
from pydantic import Base64Bytes, BaseModel, Field
class Test(BaseModel):
data: Base64Bytes = Field(min_length=10)
test = Test(data=b"") # no validation error
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 versions is a concern.\n\n
Why This Fix Works in Production
- Trigger: Base64Bytes field doesn't raises validation error for min_length constraint
- Mechanism: The Base64Bytes field did not properly enforce the min_length constraint during validation
- Why the fix works: Fixes a bug where the Base64Bytes field did not raise a validation error for the min_length constraint. (first fixed release: 1.10.19).
- 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
- The Base64Bytes field did not properly enforce the min_length constraint during validation
- Production symptom (often without a traceback): Base64Bytes field doesn't raises validation error for min_length constraint
Proof / Evidence
- GitHub issue: #9251
- Fix PR: https://github.com/pydantic/pydantic/pull/10584
- 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.62
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“@kirillklimenko, Thanks for reporting, definitely a bug! PRs welcome with a fix!”
“I would like to take a look at it! Where should I start looking at?”
“I wanna to contribute too, but, idk how to debug it, it's my first time trying to submit anything in this project. Any suggest?”
“I think this is related to encode, decode logic since even when converted Base64Bytes to Base64Str, there is no validation error too. We can avoid…”
Failure Signature (Search String)
- Base64Bytes field doesn't raises validation error for min_length constraint
- The validation should raise an error due to the minimum length constraint set for the `data` field in the `Test` model. However, no validation error is raised even though the
Copy-friendly signature
Failure Signature
-----------------
Base64Bytes field doesn't raises validation error for min_length constraint
The validation should raise an error due to the minimum length constraint set for the `data` field in the `Test` model. However, no validation error is raised even though the `data` field is empty.
Error Message
Signature-only (no traceback captured)
Error Message
-------------
Base64Bytes field doesn't raises validation error for min_length constraint
The validation should raise an error due to the minimum length constraint set for the `data` field in the `Test` model. However, no validation error is raised even though the `data` field is empty.
Minimal Reproduction
from pydantic import Base64Bytes, BaseModel, Field
class Test(BaseModel):
data: Base64Bytes = Field(min_length=10)
test = Test(data=b"") # no validation error
Environment
- Pydantic: 2
What Broke
Validation errors were not raised for empty data, leading to incorrect model behavior.
Why It Broke
The Base64Bytes field did not properly enforce the min_length constraint during validation
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/10584
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 versions is a concern.
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.