Jump to solution
Verify

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

Jump to Verify Open PR/Commit
@@ -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(
repro.py
from pydantic import Base64Bytes, BaseModel, Field class Test(BaseModel): data: Base64Bytes = Field(min_length=10) test = Test(data=b"") # no validation error
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==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).
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

  • 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

Discussion

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

“@kirillklimenko, Thanks for reporting, definitely a bug! PRs welcome with a fix!”
@sydney-runkle · 2024-04-16 · source
“I would like to take a look at it! Where should I start looking at?”
@gitFire001 · 2024-07-02 · source
“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?”
@danbailo · 2024-07-06 · source
“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…”
@RektPunk · 2024-07-13 · source

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
signature.txt
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.txt
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

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

When NOT to use: This fix should not be applied if backward compatibility with previous versions is a concern.

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.

Get updates

We publish verified fixes weekly. No spam.

Subscribe

When NOT to Use This Fix

  • This fix should not be applied if backward compatibility with previous versions is a concern.

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