Skip to content

A mistyped env_files_skip_if_set overwrites inherited variables #352

Closed

Description

@gaborbernat

In a native TOML table, a quoted env_files_skip_if_set silently allows a dotenv file to overwrite inherited variables. The plugin also exports the option itself as an environment variable.

Affected code

Native TOML option and entry parsing.

Mechanism

The option reader falls back to the INI default when the TOML value has the wrong type. The entry reader then treats the string as a normal variable. The option is reserved for a TOML boolean.

Reproduction

Run with pytest 9.2.0 at ac5583cb5181 in an empty directory on Linux.

printf '[tool.pytest_env]\nenv_files = [".env"]\nenv_files_skip_if_set = "true"\n' > pyproject.toml
printf 'MODE=file\n' > .env
printf 'import os\ndef test_settings():\n    assert (os.environ["MODE"], os.environ.get("env_files_skip_if_set")) == ("file", "true")\n' > test_config.py
MODE=inherited pytest -q

Observed 1 passed. A non-boolean option should stop pytest during configuration.

Impact

Easy to reproduce. Exposure is niche because it requires a mistyped option in a native table.

Credits

OSS Scanner report ANT-2026-H6GGI22I.

Activity

  1. added
    bug
    on Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions