From 0602d8c344c3c2717f2353bb2390dd36bd37e06e Mon Sep 17 00:00:00 2001 From: marcelsafin <179933638+marcelsafin@users.noreply.github.com> Date: Fri, 31 Jul 2026 10:25:45 +0200 Subject: [PATCH] fix(events): skip non-UTF-8 extension manifests Assisted-by: GitHub Copilot (model: GPT-5.6 Sol, autonomous) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/specify_cli/events.py | 2 +- tests/integrations/test_events.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/specify_cli/events.py b/src/specify_cli/events.py index 98e49aee36..d3002fe805 100644 --- a/src/specify_cli/events.py +++ b/src/specify_cli/events.py @@ -895,7 +895,7 @@ def collect_extension_events(project_root: Path) -> ResolvedEvents: continue try: data = yaml.safe_load(ext_yml.read_text(encoding="utf-8")) or {} - except yaml.YAMLError: + except (UnicodeDecodeError, yaml.YAMLError): continue if not isinstance(data, dict): continue diff --git a/tests/integrations/test_events.py b/tests/integrations/test_events.py index 659ae48599..084156a523 100644 --- a/tests/integrations/test_events.py +++ b/tests/integrations/test_events.py @@ -164,6 +164,13 @@ def test_invalid_yaml_skipped(self, tmp_path): (ext_dir / "extension.yml").write_text("invalid: - - -", encoding="utf-8") assert collect_extension_events(tmp_path) == {} + def test_non_utf8_manifest_skipped(self, tmp_path): + ext_dir = tmp_path / ".specify" / "extensions" / "my-ext" + ext_dir.mkdir(parents=True) + (ext_dir / "extension.yml").write_bytes(b"\xff\xfe") + + assert collect_extension_events(tmp_path) == {} + def test_event_command_ref_canonicalized_via_manifest(self, tmp_path): """R1: events are read from a validated ExtensionManifest, so an obsolete command ref (e.g. my-ext.boot) is canonicalized