Skip to content

fix(tools): report invalid UTF-8 case source paths - #961

Merged
LunaStev merged 1 commit into
wavefnd:masterfrom
hiyouwhatsapp:fix/941-case-source-utf8
Oct 19, 2026
Merged

LunaStev merged 1 commit into
wavefnd:masterfrom
hiyouwhatsapp:fix/941-case-source-utf8

Conversation

@hiyouwhatsapp

Copy link
Copy Markdown
Contributor

Fixes #941.

The case manifest's source-metadata scanner uses Path.read_text(encoding="utf-8"). It currently suppresses OSError for inaccessible source files, but a malformed UTF-8 source raises UnicodeDecodeError that escapes CaseManifestError and produces a traceback.

This catches only UnicodeDecodeError at the source read, rethrowing it as a path-aware CaseManifestError with the original decode error as its cause. The existing OSError behavior and valid UTF-8 scanning are unchanged.

Coverage

  • Invalid UTF-8 bytes in a case directive comment and after a normal source statement.
  • A valid non-ASCII UTF-8 comment and source body.
  • The existing validate CLI's diagnostic/exit-code-2 behavior without a traceback.

Verification

  • Two isolated decoding cases reproduced uncaught UnicodeDecodeError with the old helper; both passed after the fix; the valid UTF-8 control also passed.
  • Diff reviewed and checked for trailing whitespace.
  • The complete repository tools.test_case_manifest suite could not run locally because a full Wave checkout is unavailable here; CI verification remains necessary.

Translate case-source decoding failures to CaseManifestError with a relative
path. Exercise invalid comment/body bytes, valid Unicode, and the existing
validate exit-code-2 error contract without a traceback.

Fixes wavefnd#941

Signed-off-by: hiyouwhatsapp <[email protected]>

@LunaStev LunaStev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed the targeted UTF-8 decode exception handling, path-aware diagnostic, and CLI exit-code regression tests. CI passes.

@LunaStev
LunaStev merged commit 9845fe5 into wavefnd:master Oct 19, 2026
35 checks passed
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.

Report invalid UTF-8 case source metadata without a manifest-loader traceback

2 participants