Jump to solution
Verify

The Fix

pip install pydantic==2.6.2

Based on closed pydantic/pydantic issue #8674 · PR/commit linked

Jump to Verify Open PR/Commit
@@ -109,6 +109,14 @@ def validator( function to be used as a validator. """ + warn( + 'Pydantic V1 style `@validator` validators are deprecated.' + ' You should migrate to Pydantic V2 style `@field_validator` validators,'
repro.py
class Model(BaseModel): a: str with pytest.warns(PydanticDeprecatedSince20, match=V1_VALIDATOR_DEPRECATION_MATCH): @validator
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.6.2\nWhen NOT to use: Do not use if it changes public behavior or if the failure cannot be reproduced.\n\n

Why This Fix Works in Production

  • Trigger: Test regressions with pytest 8.0.0
  • Mechanism: Fixes test failures with pytest-8.0.0 due to changes in how pytest handles warnings inside exceptions.
  • Why the fix works: Fixes test failures with pytest-8.0.0 due to changes in how pytest handles warnings inside exceptions. (first fixed release: 2.6.2).

Why This Breaks in Prod

  • Shows up under Python 3.11.7 in real deployments (not just unit tests).
  • Production symptom (often without a traceback): Test regressions with pytest 8.0.0

Proof / Evidence

Discussion

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

“For the record, I've seen a similar issue with one more package but here it looks it could actually be a pytest bug. I've gotta…”
@mgorny · 2024-01-30 · source
“I'm preparing a pull request to address at last some of the failures.”
@mgorny · 2024-01-30 · source
“Ok, I think this is actually a bug in the test suite”
@mgorny · 2024-01-30 · source

Failure Signature (Search String)

  • Test regressions with pytest 8.0.0
  • When running the test suite using `pytest 8.0.0`, the following test regressions are seen:
Copy-friendly signature
signature.txt
Failure Signature ----------------- Test regressions with pytest 8.0.0 When running the test suite using `pytest 8.0.0`, the following test regressions are seen:

Error Message

Signature-only (no traceback captured)
error.txt
Error Message ------------- Test regressions with pytest 8.0.0 When running the test suite using `pytest 8.0.0`, the following test regressions are seen:

Minimal Reproduction

repro.py
class Model(BaseModel): a: str with pytest.warns(PydanticDeprecatedSince20, match=V1_VALIDATOR_DEPRECATION_MATCH): @validator

Environment

  • Python: 3.11.7
  • Pydantic: 2

What Broke

Tests fail to emit expected warnings, leading to incorrect test results.

Fix Options (Details)

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

pip install pydantic==2.6.2

When NOT to use: Do not use if it changes public behavior or if the failure cannot be reproduced.

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

First fixed release: 2.6.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

  • Do not use if it changes public behavior or if the failure cannot be reproduced.

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

Related Issues

No related fixes found.

Sources

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