fix(events): skip non-UTF-8 extension manifests (#3900)

Assisted-by: GitHub Copilot (model: GPT-5.6 Sol, autonomous)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Marsel Safin
2026-08-03 08:40:54 -05:00
committed by GitHub
co-authored by Copilot
parent d1e86f6382
commit 4343cd5e80
2 changed files with 8 additions and 1 deletions
+1 -1
View File
@@ -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
+7
View File
@@ -164,6 +164,13 @@ class TestCollectExtensionEvents:
(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