fix(cli): handle TOML syntax errors gracefully#221
Merged
tomschr merged 4 commits intoopenSUSE:mainfrom Apr 22, 2026
Merged
Conversation
Signed-off-by: sushant-suse <[email protected]>
Coverage ReportFor commit 54bc798 Click to expand Coverage Report Name Stmts Miss Branch BrPart Cover
--------------------------------------------------------------------------------
+ src/docbuild/models/deliverable.py 180 1 22 0 99.5%
+ src/docbuild/cli/cmd_check/process.py 58 0 22 1 98.8%
+ src/docbuild/models/manifest.py 111 1 12 1 98.4%
+ src/docbuild/utils/pidlock.py 79 1 14 1 97.8%
+ src/docbuild/cli/cmd_cli.py 106 1 12 2 97.5%
+ src/docbuild/cli/cmd_validate/process.py 178 5 52 4 96.1%
+ src/docbuild/cli/callback.py 35 0 10 2 95.6%
+ src/docbuild/utils/concurrency.py 69 3 18 1 95.4%
- src/docbuild/cli/cmd_config/__init__.py 9 1 0 0 88.9%
- src/docbuild/config/xml/stitch.py 47 5 12 0 88.1%
- src/docbuild/cli/cmd_metadata/metaprocess.py 215 26 66 13 82.6%
- src/docbuild/cli/cmd_check/__init__.py 18 5 2 0 65.0%
- src/docbuild/cli/cmd_build/__init__.py 13 5 0 0 61.5%
- src/docbuild/cli/cmd_metadata/__init__.py 27 10 2 0 58.6%
- src/docbuild/cli/cmd_config/environment.py 11 6 2 0 38.5%
--------------------------------------------------------------------------------
+ TOTAL 3011 70 708 25 97.0%
46 files skipped due to complete coverage. |
Signed-off-by: sushant-suse <[email protected]>
tomschr
requested changes
Apr 21, 2026
Contributor
tomschr
left a comment
There was a problem hiding this comment.
Thanks @sushant-suse for the work. 👍 It took a bit longer for me.
Overall it looks good. 👍 Apart from minor details, I have some concerns regarding an anti pattern (see below). Not sure if we want to fix it here in this PR as it deviates from the original issue.
Signed-off-by: sushant-suse <[email protected]>
tomschr
requested changes
Apr 22, 2026
Contributor
tomschr
left a comment
There was a problem hiding this comment.
Just a tiny addition, otherwise it's great. 👍 Thank you! I think, it's ready to be squash-merged to main.
Collaborator
Author
Also forgot to add fragment file. Added that as well. |
Signed-off-by: sushant-suse <[email protected]>
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.
Changes
Core Logic & CLI
src/docbuild/cli/cmd_cli.py:handle_configcalls for both Application and Environment configurations intry...exceptblocks to catchtomllib.TOMLDecodeError.handle_validation_error(and its internal logic) to distinguish between TOML syntax errors and Pydantic validation errors.Utilities
src/docbuild/utils/errors.py:format_toml_errorfunction. This uses therichlibrary to print a clean, red-styled error panel.Tests
tests/utils/test_errors.py: Added a test to verify that theformat_toml_errorutility correctly captures and formats a syntax error.tests/cli/test_cmd_cli.py: Added an end-to-end test that mocks aTOMLDecodeErrorduring the CLI initialization to verify the program exits with code1and displays the correct error message without a traceback.