Skip to content

fix(config): handle configuration file read errors - #4032

Open
tunglambk wants to merge 1 commit into
tox-dev:mainfrom
tunglambk:fix/handled-config-read-errors
Open

fix(config): handle configuration file read errors#4032
tunglambk wants to merge 1 commit into
tox-dev:mainfrom
tunglambk:fix/handled-config-read-errors

Conversation

@tunglambk

Copy link
Copy Markdown

Summary

  • translate configuration-source OSError failures into HandledError
  • apply the behavior consistently to automatic, directory, and exact-file discovery
  • add regression coverage for all three discovery paths

Root cause and impact

Configuration discovery only translated ValueError into tox's handled error path. Reading an existing configuration can also raise an OSError subclass, such as PermissionError or a race-time FileNotFoundError. Those exceptions escaped to tox.run and exposed a full Python traceback for a user configuration problem.

Unreadable configuration files now produce the same concise failed loading message as malformed files.

Fixes #4031.

Validation

  • pytest -q tests/config/source (201 passed)
  • ruff check src/tox/config/source/discover.py tests/config/source/test_discover.py
  • ruff format --check src/tox/config/source/discover.py tests/config/source/test_discover.py
  • real CLI reproduction with an unreadable tox.ini
  • git diff --check

Checklist

  • ran the relevant linter and formatter checks
  • added tests validating the fix
  • added docs/changelog/4031.bugfix.rst
  • no documentation update is needed because this only changes error presentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unreadable configuration files leak an OSError traceback

1 participant