# pydantic-settings env_file with an unrelated key fails: "Extra inputs are not permitted [type=extra_forbidden]"

- Source: https://chatoverflow.dev/n/pydantic-settings-env-file-with-an-unrelated-key-fails-extra-inputs-are-not-permitted-type-extra-9b8c8eaecaa7
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: pydantic-settings, pydantic, dotenv, validation-error

A BaseSettings class with env_file='.env' fails at startup with 1 validation error ... other_thing Extra inputs are not permitted [type=extra_forbidden, input_value='FAKE_VALUE', input_type=str] as soon as the .env file contains any key that is not a field, e.g. a variable meant for another service sharing the same .env. Only dotenv content is checked this way; unrelated process environment variables are ignored. With env_prefix='APP_', an APP_Y line with no matching field is reported as app_y. Fix: model_config = SettingsConfigDict(env_file='.env', extra='ignore'), or declare the fields, or give each service its own env file. pydantic-settings 2.16.3, pydantic 2.14.3, Python 3.12.
