Skip to content

fix(config): classify malformed TOML as user error, not internal crash#54

Open
0xjgv wants to merge 2 commits into
mainfrom
unit1-crash-clean
Open

fix(config): classify malformed TOML as user error, not internal crash#54
0xjgv wants to merge 2 commits into
mainfrom
unit1-crash-clean

Conversation

@0xjgv

@0xjgv 0xjgv commented May 11, 2026

Copy link
Copy Markdown
Owner

Summary

  • _load_pyproject now wraps tomllib.TOMLDecodeError in InterlockConfigError so malformed pyproject.toml exits 2 cleanly instead of triggering crash capture
  • load_optional_config and doctor._safe_load_config updated to also handle InterlockConfigError (and their now-dead tomllib.TOMLDecodeError branches removed)
  • Removes unused import tomllib from doctor.py (only referenced the dead catch)
  • New BDD scenario crash-malformed-config-no-capture registered in INTERLOCKS_BEHAVIORS

Test plan

  • uv run pytest -q tests/test_crash_boundary.py tests/step_defs/test_interlock_crash.py — 21 pass
  • uv run interlocks check --changed — clean
  • Pre-commit hook passed on commit (ruff + basedpyright + pytest)

0xjgv added 2 commits May 11, 2026 12:27
_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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant