fix(cli): clean error (not a traceback) when run outside a rendered project - #93
Merged
Conversation
…roject (#92) Running the console script from a directory with no pdca.toml raised an uncaught FileNotFoundError — the user saw a full Python traceback (config._find_root → Config.load → cli.main) that reads like a crash. The message was already helpful; only the surfacing was wrong. cli.main() now wraps Config.load(): a FileNotFoundError prints its message ("no pdca.toml found … — run inside a rendered project") and a malformed pdca.toml (ValueError / tomllib) prints "pdca: invalid pdca.toml — …"; both exit 2, no traceback. --help and a valid in-project run are unchanged. Test: CliSurface.test_no_pdca_toml_is_clean_error_not_traceback — outside a rendered project, `status` exits 2 with one clean line and no "Traceback". Suite green (154). Closes #92. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Eduard Ralph <15236434+eduralph@users.noreply.github.com>
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
Closes #92. Running the console script from a directory with no
pdca.tomlraised an uncaughtFileNotFoundError— the user saw a full Python traceback that reads like a crash (seen contributing into the Wyrd instance; works fromwyrd-pdca/, not its parent):The message was already helpful; only the surfacing was wrong.
Fix
cli.main()wrapsConfig.load():FileNotFoundError→ print its message (no pdca.toml found … — run inside a rendered project), exit 2.pdca.toml(ValueError/ tomllib) →pdca: invalid pdca.toml — …, exit 2.No traceback either way.
--helpand a valid in-project run are unchanged. Template-side, so every instance (gramps included) gets it on the nextcopier update.Verification
CliSurface.test_no_pdca_toml_is_clean_error_not_traceback(outside a project,statusexits 2 with one clean line, noTraceback)./tmp: prints the one-line message,exit=2.🤖 Generated with Claude Code