Skip to content

🐛 fix(cli): allow --help with invalid config#3821

Merged
gaborbernat merged 2 commits intotox-dev:mainfrom
gaborbernat:3819
Feb 24, 2026
Merged

🐛 fix(cli): allow --help with invalid config#3821
gaborbernat merged 2 commits intotox-dev:mainfrom
gaborbernat:3819

Conversation

@gaborbernat
Copy link
Copy Markdown
Member

Config discovery errors were preventing --help from rendering because _get_base() calls discover_source() which raises HandledError on malformed config files. This propagates before argparse can display help output in _get_all(). Fixes #3819.

When --help is requested and config loading fails, tox now falls back to an empty source so users can still access help output regardless of config state. This only applies when -h or --help is in the arguments — all other invocations still raise the config error as before.

Config discovery errors were preventing --help from rendering because
_get_base() calls discover_source() after catching the SystemExit from
argparse's help handling. When the config file is malformed, the
HandledError propagates before argparse can display help in _get_all().

Fall back to an empty source when help is requested and config loading
fails, so users can still access help output regardless of config state.

Fixes tox-dev#3819
@gaborbernat gaborbernat added the bug:normal affects many people or has quite an impact label Feb 24, 2026
@gaborbernat gaborbernat merged commit 38d1a49 into tox-dev:main Feb 24, 2026
52 of 53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:provided bug:normal affects many people or has quite an impact

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Invalid tox.toml prevents invocation of --help

1 participant