fix(config): classify malformed TOML as user error, not internal crash#54
Open
0xjgv wants to merge 2 commits into
Open
fix(config): classify malformed TOML as user error, not internal crash#540xjgv wants to merge 2 commits into
0xjgv wants to merge 2 commits into
Conversation
_load_pyproject now wraps tomllib.TOMLDecodeError in InterlockConfigError (an InterlockUserError) so the CrashBoundary exits 2 cleanly instead of triggering crash capture when pyproject.toml is malformed. load_optional_config and doctor._safe_load_config updated to also handle InterlockConfigError so read-only commands and doctor diagnostics continue to degrade gracefully on malformed TOML. Tests: two focused unit probes in test_crash_boundary.py and a new BDD scenario in interlock_crash.feature with its step def.
…ed-config behavior _load_pyproject now converts TOMLDecodeError → InterlockConfigError, so tomllib.TOMLDecodeError can no longer propagate to callers. Remove the dead branch from load_optional_config and doctor._safe_load_config; drop the now-unused `import tomllib` from doctor. Add crash-malformed-config-no-capture to INTERLOCKS_BEHAVIORS so the new BDD scenario is tracked by behavior attribution.
There was a problem hiding this comment.
Code Review
This pull request ensures that a malformed pyproject.toml file is correctly identified as a user configuration error rather than an internal application crash. It achieves this by catching tomllib.TOMLDecodeError and raising a custom InterlockConfigError, which is then handled to exit cleanly with code 2. New tests have been added to verify this behavior and confirm that no crash report is generated for malformed configuration files. I have no feedback to provide.
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.
Summary
_load_pyprojectnow wrapstomllib.TOMLDecodeErrorinInterlockConfigErrorso malformedpyproject.tomlexits 2 cleanly instead of triggering crash captureload_optional_configanddoctor._safe_load_configupdated to also handleInterlockConfigError(and their now-deadtomllib.TOMLDecodeErrorbranches removed)import tomllibfromdoctor.py(only referenced the dead catch)crash-malformed-config-no-captureregistered inINTERLOCKS_BEHAVIORSTest plan
uv run pytest -q tests/test_crash_boundary.py tests/step_defs/test_interlock_crash.py— 21 passuv run interlocks check --changed— clean