Jump to solution
Verify

The Fix

pip install pydantic==2.9.2

Based on closed pydantic/pydantic issue #10335 · 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
@@ -700,7 +700,7 @@ print(t.model_dump(include={'id': True, 'user': {'id'}})) ``` -The `True` indicates that we want to exclude or include an entire key, just as if we included it in a set. +Using `True` indicates that we want to exclude or include an entire key, just as if we included it in a set (note that using `False` isn't supported). This can be done at any depth level.
repro.py
from pydantic import BaseModel class Simple(BaseModel): a: int Simple(a=1).model_dump(include={'a': False}) #> {'a': 1} # 'a': False was ignored
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 should not be used if the intention is to allow `False` in the `include` argument.\n\n

Why This Fix Works in Production

  • Trigger: `include`/`exclude` doesn't work when using `False`
  • Mechanism: The `include` argument in `model_dump` incorrectly accepted `False`, leading to unexpected behavior
  • Why the fix works: Fixes the variance issue in the `_IncEx` type alias by only allowing `True` as a valid value for inclusion in model dumps. (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

  • The `include` argument in `model_dump` incorrectly accepted `False`, leading to unexpected behavior
  • Production symptom (often without a traceback): `include`/`exclude` doesn't work when using `False`

Proof / Evidence

Verified Execution

We executed the runnable minimal repro in a temporary environment and captured exit codes + logs.

  • Status: PASS
  • Ran: 2026-02-11T16:52:29Z
  • Package: pydantic
  • Fixed: 2.9.2
  • Mode: fixed_only
  • Outcome: ok
Logs
affected (exit=None)
fixed (exit=0)

Discussion

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

“We decided to change the type annotation to only allow Literal[True]. Probably also switching to Mapping (https://github.com/pydantic/pydantic/issues/10333#issuecomment-2343387221).”
@Viicos · 2024-09-11 · source
“We've deprecated include for the Field() constructor, probably makes sense to do the same for model_dump_xxx. Important question - can we do this in v2?”
@sydney-runkle · 2024-09-10 · source
“> probably makes sense to do the same for model_dump_xxx”
@Viicos · 2024-09-10 · source
“> Using include in model_dump* is semantically different: only the fields specified will be included, and the others will be excluded”
@sydney-runkle · 2024-09-10 · source

Failure Signature (Search String)

  • `include`/`exclude` doesn't work when using `False`
  • Ahh right, I forgot about this behavioral difference. So we can't remove it then. Let's chat tomorrow re next steps here - happy to help make this API more consistent.
Copy-friendly signature
signature.txt
Failure Signature ----------------- `include`/`exclude` doesn't work when using `False` Ahh right, I forgot about this behavioral difference. So we can't remove it then. Let's chat tomorrow re next steps here - happy to help make this API more consistent.

Error Message

Signature-only (no traceback captured)
error.txt
Error Message ------------- `include`/`exclude` doesn't work when using `False` Ahh right, I forgot about this behavioral difference. So we can't remove it then. Let's chat tomorrow re next steps here - happy to help make this API more consistent.

Minimal Reproduction

repro.py
from pydantic import BaseModel class Simple(BaseModel): a: int Simple(a=1).model_dump(include={'a': False}) #> {'a': 1} # 'a': False was ignored

Environment

  • Pydantic: 2

What Broke

Users experienced incorrect serialization results when using `False` in the `include` argument.

Why It Broke

The `include` argument in `model_dump` incorrectly accepted `False`, leading to unexpected behavior

Fix Options (Details)

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

pip install pydantic==2.9.2

When NOT to use: This fix should not be used if the intention is to allow `False` in the `include` argument.

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

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 should not be used if the intention is to allow `False` in the `include` argument.

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.