You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Handle structkit validate missing-file and YAML parse errors cleanly #163
structkit validate currently lets expected user/config errors bubble up as Python tracebacks. Missing files, invalid YAML, and validation ValueErrors should be presented as concise CLI errors with exit code 1.
Evidence
Observed locally with the current code:
python -m structkit.main validate /tmp/.../missing.yaml
Traceback ...
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/.../missing.yaml'
python -m structkit.main validate /tmp/.../invalid.yaml
Traceback ...
yaml.parser.ParserError: while parsing a flow node
Relevant code:
structkit/commands/validate.py:16-35 opens and parses YAML without catching OSError or yaml.YAMLError.
_validate_* helpers raise ValueError directly, which currently reaches the CLI boundary as a traceback.
Proposed fix
Introduce/catch a domain validation error at the command boundary.
Catch FileNotFoundError / OSError and yaml.YAMLError in ValidateCommand.execute.
Log errors with the same style as other commands, e.g. ❗ File not found: ... or ❗ Invalid YAML in ....
Exit non-zero via SystemExit(1) without printing a traceback.
Acceptance criteria
Missing validate target exits 1 with a clean one-line error and no Traceback.
Invalid YAML exits 1 with a clean error that includes file path and parser detail.
Schema validation failures exit 1 with clean messages and no Traceback.
Tests cover missing file, invalid YAML, and invalid config shape.
Activity