The Fix
pip install pydantic==2.11.8
Based on closed pydantic/pydantic issue #12362 · 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%.
@@ -288,7 +288,7 @@ By leveraging the new [`type` statement](https://typing.readthedocs.io/en/latest
=== "Python 3.9 and above"
- ```python
+ ```python {test="skip"}
from typing import Annotated
from ixmp4.db import Session, filters, sql
class OptimizationScalarFilter(filters.BaseFilter, metaclass=filters.FilterMeta):
id: filters.Id | None = filters.Field(None)
name: filters.String | None = filters.Field(None)
run__id: filters.Integer | None = filters.Field(None, alias="run_id")
unit__id: filters.Integer | None = filters.Field(None, alias="unit_id")
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==2.11.8\nWhen NOT to use: This fix is not applicable if using unsupported field attributes intentionally.\n\nOption C — Workaround\n[here](https://github.com/pydantic/pydantic/pull/11898/files#diff-bfaaac2ae0a71d9686a272982d29d0bed82bfaacf8b5b30e2b88ed2543e74a3bL216-R217), and opened [a PR](https://github.com/iiasa/ixmp4/pull/206) to incorporate the fix on our side.\nWhen NOT to use: This fix is not applicable if using unsupported field attributes intentionally.\n\n
Why This Fix Works in Production
- Trigger: E ixmp4.core.exceptions.BadFilterArguments: OptimizationScalarFilter [{'type': 'extra_forbidden', 'loc': ['run_id'], 'msg': 'Extra inputs are not…
- Mechanism: The 'alias' attribute was used in invalid contexts, leading to warnings
- Why the fix works: Emit warning when field-specific metadata is used in invalid contexts. (first fixed release: 2.11.8).
- 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
- Shows up under Python 3.12 in real deployments (not just unit tests).
- The 'alias' attribute was used in invalid contexts, leading to warnings
- Surfaces as: E ixmp4.core.exceptions.BadFilterArguments: OptimizationScalarFilter [{'type': 'extra_forbidden', 'loc': ['run_id'], 'msg': 'Extra inputs are not permitted', 'input': 1, 'url':…
Proof / Evidence
- GitHub issue: #12362
- Fix PR: https://github.com/pydantic/pydantic/pull/12028
- First fixed release: 2.11.8
- 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.61
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“@kamzil lets keep the discussion in https://github.com/pydantic/pydantic/pull/12028. A MRE would help, as the following: does not emit any warning on my end.”
“We're getting these warnings with pydantic 2.12.3. We have a base model we use with all our models, defined like this: Is something wrong with…”
“Upgrading to the latest FastAPI version will fix these warnings”
Failure Signature (Search String)
- E ixmp4.core.exceptions.BadFilterArguments: OptimizationScalarFilter [{'type': 'extra_forbidden', 'loc': ['run_id'], 'msg': 'Extra inputs are not permitted', 'input': 1,
Error Message
Stack trace
Error Message
-------------
E ixmp4.core.exceptions.BadFilterArguments: OptimizationScalarFilter [{'type': 'extra_forbidden', 'loc': ['run_id'], 'msg': 'Extra inputs are not permitted', 'input': 1, 'url': 'https://errors.pydantic.dev/2.12/v/extra_forbidden'}]
Minimal Reproduction
from ixmp4.db import Session, filters, sql
class OptimizationScalarFilter(filters.BaseFilter, metaclass=filters.FilterMeta):
id: filters.Id | None = filters.Field(None)
name: filters.String | None = filters.Field(None)
run__id: filters.Integer | None = filters.Field(None, alias="run_id")
unit__id: filters.Integer | None = filters.Field(None, alias="unit_id")
Environment
- Python: 3.12
- Pydantic: 2
What Broke
CI suite failed due to warnings affecting the filtering system.
Why It Broke
The 'alias' attribute was used in invalid contexts, leading to warnings
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install pydantic==2.11.8
Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.
Option C — Workaround Temporary workaround
[here](https://github.com/pydantic/pydantic/pull/11898/files#diff-bfaaac2ae0a71d9686a272982d29d0bed82bfaacf8b5b30e2b88ed2543e74a3bL216-R217), and opened [a PR](https://github.com/iiasa/ixmp4/pull/206) to incorporate the fix on our side.
Use only if you cannot change versions today. Treat this as a stopgap and remove once upgraded.
Fix reference: https://github.com/pydantic/pydantic/pull/12028
First fixed release: 2.11.8
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix is not applicable if using unsupported field attributes intentionally.
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 |
|---|---|
| 2.11.8 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.