Skip to content

fix(tools): report invalid UTF-8 case manifests as CaseManifestError - #689

Merged
LunaStev merged 1 commit into
wavefnd:masterfrom
subikshajegadish:fix/case-manifest-utf8-errors
Sep 22, 2026
Merged

LunaStev merged 1 commit into
wavefnd:masterfrom
subikshajegadish:fix/case-manifest-utf8-errors

Conversation

@subikshajegadish

Copy link
Copy Markdown
Contributor

Summary

Catch UnicodeDecodeError in load_case_manifest alongside OSError and TOMLDecodeError, so invalid UTF-8 in the case manifest is reported as a CaseManifestError that includes the manifest path and the decoding details.

Motivation

Fixes #688.

load_case_manifest in tools/case_manifest.py reads the manifest as UTF-8 but did not handle decoding errors. Invalid bytes escaped as a raw UnicodeDecodeError without the manifest path, bypassing the CLI's invalid case manifest diagnostic and exit status 2.

Target and compatibility impact

None. This only affects error reporting in the Python case manifest tooling. Valid manifests load unchanged, TOML syntax and filesystem errors are handled as before, and no replacement decoding is used.

Validation

  • Added test_invalid_utf8_manifest_reports_path_in_case_manifest_error: a temporary manifest containing \xff raises CaseManifestError with the manifest path and decoding context, and preserves the UnicodeDecodeError as its cause. This test fails without the fix.
  • Added test_manifest_accepts_non_ascii_utf8_comments: the repository manifest with a prepended non-ASCII UTF-8 comment loads identically to the original.
  • Manually verified that python3 tools/case_manifest.py validate pointed at an invalid UTF-8 manifest prints invalid case manifest: cannot read case manifest <path>: 'utf-8' codec can't decode byte 0xff ... and exits 2 without a traceback.
  • python3 tools/case_manifest.py validate on the repository manifest still passes.
  • python3 -m py_compile ... (full list from CONTRIBUTING.md) passes.
  • python3 -m unittest tools.test_case_manifest tools.test_test_contracts tools.test_process_tree passes (38 tests, 1 Windows-only skip).

Checklist

  • Commits include a DCO Signed-off-by line.
  • Tests cover new behavior or the PR explains why no test is needed.
  • User-facing changes include documentation or diagnostics updates.
  • The change preserves the license boundary between the compiler and std/.

@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.

LGTM, thank you for your contribution!

@LunaStev
LunaStev merged commit 2b32548 into wavefnd:master Sep 22, 2026
23 of 25 checks passed
@LunaStev LunaStev mentioned this pull request Sep 30, 2026
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 manifests through CaseManifestError

2 participants