Repository navigation
🐛 fix(toml): validate native entry tables - #338
Merged
gaborbernat merged 1 commit intoNov 17, 2026
Merged
Conversation
An entry table was applied whatever it held. Flags went through bool(), so `unset = "false"` removed the variable; a missing or misspelled `value` assigned the empty string; and an unquoted dotted name, which TOML reads as a nested table, created an empty variable named after its first part. The run passed each time. Such a table now stops pytest with a usage error that names the entry. Reported by Anthropic's OSS Scanner: ANT-2026-VTKFPKVK. Fixes pytest-dev#324
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The table branch of
_parse_toml_configapplied an entry in[pytest_env]or[tool.pytest_env]without validating it (old lines). A malformed entry produced an environment its author did not write, and the run passed:unset = "false"removed the variable,{ vaule = "x" }replaced an existing variable with the empty string, and an unquotedDATABASE.HOST = "x"created an emptyDATABASE. 🐛 After this PR such an entry stops pytest with a usage error that names it. Fixes #324.Flags were read through
bool()unset,transformandskip_if_setwent throughbool(), so any non-empty string counted as true,"false"included._parse_toml_tablenow requires each flag that is present to be a TOML boolean.Unknown keys and a missing value were accepted
A table without
valuedefaulted to the empty string, and keys other than the four documented ones were ignored, which is how a misspelledvaluebecame an assignment of"". TOML reads an unquoted dotted key as a nested table, soDATABASE.HOST = "x"arrived as an entry namedDATABASEwhose table holds onlyHOST. The parser now rejects any key outsidevalue,transform,skip_if_setandunset, and a table that has neithervaluenorunset = true.Behavior changes
A malformed table stops pytest before collection with exit code 4 and one of:
The messages hold the entry name and the key, not the value. A configuration that relied on a table without
valueto assign the empty string has to writevalue = "". A variable name with a dot has to be quoted, as in"DATABASE.HOST" = "x". Plain values, valid tables and INIenvlines behave as before.Reported by Anthropic's OSS Scanner: ANT-2026-VTKFPKVK.