Jump to solution
Verify

The Fix

pip install pydantic==2.10.4

Based on closed pydantic/pydantic issue #10474 · 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
@@ -761,6 +761,10 @@ def collect_field_or_class_var_from_stmt( # noqa C901 node.type = AnyType(TypeOfAny.from_error) + if node.is_final and has_default: + # TODO this path should be removed (see https://github.com/pydantic/pydantic/issues/11119) + return PydanticModelClassVar(lhs.name)
repro.py
from typing import Final from pydantic import RootModel class A(RootModel[str]): a: Final = 1 # error: Only `root` is allowed as a field of a `RootModel` [pydantic-field]
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.10.4\nWhen NOT to use: This fix is not applicable if the behavior of Final fields is intended to change in future versions.\n\n

Why This Fix Works in Production

  • Trigger: (🐞) false positive mypy error "Only `root` is allowed as a field of a `RootModel`"
  • Mechanism: The mypy plugin incorrectly handles Final fields with default values in RootModel
  • Why the fix works: Fixes a false positive mypy error regarding Final fields in RootModel by correctly inferring them as class variables. (first fixed release: 2.10.4).
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 mypy plugin incorrectly handles Final fields with default values in RootModel
  • Production symptom (often without a traceback): (🐞) false positive mypy error "Only `root` is allowed as a field of a `RootModel`"

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.10.4
  • Mode: fixed_only
  • Outcome: ok
Logs
affected (exit=None)
fixed (exit=0)

Discussion

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

“This will be fixed in https://github.com/pydantic/pydantic/pull/11121”
@Viicos · 2024-12-15 · confirmation · source
“The typing specification regarding Final was updated this year, and it seems that we don't apply the same semantics, but we probably should”
@Viicos · 2024-11-15 · source
“Indeed, looks like a bug. Fixing is relatively low priority, but PRs welcome!”
@sydney-runkle · 2024-09-25 · source

Failure Signature (Search String)

  • (🐞) false positive mypy error "Only `root` is allowed as a field of a `RootModel`"
  • a `Final` with a default value is not a field, it's a `ClassVar`, and pydantic correctly handles this at runtime, but the mypy plugin is incorrect here
Copy-friendly signature
signature.txt
Failure Signature ----------------- (🐞) false positive mypy error "Only `root` is allowed as a field of a `RootModel`" a `Final` with a default value is not a field, it's a `ClassVar`, and pydantic correctly handles this at runtime, but the mypy plugin is incorrect here

Error Message

Signature-only (no traceback captured)
error.txt
Error Message ------------- (🐞) false positive mypy error "Only `root` is allowed as a field of a `RootModel`" a `Final` with a default value is not a field, it's a `ClassVar`, and pydantic correctly handles this at runtime, but the mypy plugin is incorrect here

Minimal Reproduction

repro.py
from typing import Final from pydantic import RootModel class A(RootModel[str]): a: Final = 1 # error: Only `root` is allowed as a field of a `RootModel` [pydantic-field]

Environment

  • Pydantic: 2

What Broke

Developers encounter false positive errors when using Final fields in RootModel, causing confusion.

Why It Broke

The mypy plugin incorrectly handles Final fields with default values in RootModel

Fix Options (Details)

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

pip install pydantic==2.10.4

When NOT to use: This fix is not applicable if the behavior of Final fields is intended to change in future versions.

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

First fixed release: 2.10.4

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 if the behavior of Final fields is intended to change in future versions.

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

Related Issues

No related fixes found.

Sources

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