Skip to content

fix(cli): handle non-UTF-8 source files - #61

Open
xuu33030 wants to merge 1 commit into
alphacrack:mainfrom
xuu33030:fix/issue-27-non-utf8-cli
Open

xuu33030 wants to merge 1 commit into
alphacrack:mainfrom
xuu33030:fix/issue-27-non-utf8-cli

Conversation

@xuu33030

Copy link
Copy Markdown

Summary

Handle invalid UTF-8 and file-read failures before linting or executing a .dmai source file. Invalid encodings now produce a concise Maithili message and dedicated exit code instead of a raw Python traceback.

Motivation / Audit Reference

Closes #27.

Test Evidence

  • pytest -v --cov=maithili_dsl --cov-report=term-missing — 162 passed, 95.00% total coverage; cli.py 97%
  • New CLI and security regression tests cover invalid UTF-8 input
  • All example programs smoke-tested; error.dmai failed as expected
  • python -m maithili_dsl --version reports 0.4.0
  • Real subprocess verification returned exit code 7, printed the Maithili UTF-8 error, and emitted no traceback

Security Considerations

The file is still read before any linting, transpilation, import validation, or execution. Malformed input now fails closed at that boundary. The generic OSError message does not expose local path or exception details.

Breaking Changes

None. Valid UTF-8 programs retain their existing behavior and exit codes. Invalid encodings now have the documented non-zero EXIT_BAD_ENCODING code instead of an uncaught exception.

Checklist

  • CHANGELOG.md updated (Unreleased section)
  • Version bumped if this is a release PR (not applicable)
  • No new runtime dependencies added
  • User-visible error behavior documented in CHANGELOG.md

This branch has not been deployed

No deployments
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.

[BUG] CLI crashes with raw traceback on non-UTF-8 .dmai files

1 participant