REVIEWABLE PREVIEW · 12 MEASURED CHECKS

Pydantic Settings: extra_forbidden hides a nested configuration loss

Reproduced Pydantic Settings extra_forbidden: Extra inputs are not permitted. Explicit AliasChoices preserves nested dotenv values and source precedence.

What this material covers

3 validation errors for BrokenSettings
lab_service_settings__primary_endpoint
  Extra inputs are not permitted [type=extra_forbidden, input_value='https://file-primary.example.invalid', input_type=str]
    For further information visit https://errors.pydantic.dev/2.13/v/extra_forbidden
lab_service_settings__fallback_endpoint
  Extra inputs are not permitted [type=extra_forbidden, input_value='https://file-fallback.example.invalid', input_type=str]
    For further information visit https://errors.pydantic.dev/2.13/v/extra_forbidden
lab_service_settings__timeout_seconds
  Extra inputs are not permitted [type=extra_forbidden, input_value='15', input_type=str]
    For further information visit https://errors.pydantic.dev/2.13/v/extra_forbidden

Use explicit AliasChoices for both accepted prefixes; keep strict extras and package versions unchanged

Measured on Windows AMD64, CPython 3.12.14, pydantic-settings 2.15.0, pydantic 2.13.5, pydantic-core 2.46.5 and python-dotenv 1.2.3. One nested model receives LAB_ synthetic environment and dotenv inputs with different intentional prefixes. Reproduced actual extra_forbidden errors, then demonstrated that extra='ignore' loses fallback and timeout inputs. Explicit AliasChoices preserves source precedence, fallback and numeric types while rejecting unknown or malformed input. No package versions changed. Subprocesses inherit no user environment; on Windows only SYSTEMROOT obtained from GetWindowsDirectoryW is supplied for asyncio bootstrap, then every evaluation clears all variables and installs only LAB_ fixture values. Evaluations read only a temporary explicit public fixture. No actual user environment values or project .env file, private value or network destination was used. Deep aliases, custom sources, case-sensitive configurations, same-source dual-alias collisions, secret stores, production deployment and external AI demand were not tested. Expanding accepted names is a deliberate input-contract change, not a blanket instruction to accept aliases. Customer final verification remains required.

Measured 2026-09-09T11:30:32.962092+00:00 · Windows / AMD64. Historical package versions are not current production recommendations.

Primary references

Use this preview to decide what you would question, test, clarify or add. A brief response opens the full execution record, exact environments and reproduction files.

Review → respond → receive

Share one short reaction to the preview above to open the detailed record and reproduction files. The same feedback access works for these files for 24 hours.

One brief response to the material · required

After reviewing the preview, leave an opinion, test idea, related experience, another case or a question. One or two specific sentences are enough. You do not need to run anything or agree with the material.

Private by default. A required response is counted separately from voluntary demand and execution results. Specific text is required; its truth is not automatically verified.

Responses from readers · unverified

Only notes explicitly authorized for public display appear here. Required responses are not independent verification or spontaneous demand.

No public reader responses yet.

Have a complete reproducible solution? Submit it for review →