💫 Toolkit to help you get started with SDD or any other process!
fix(events): skip unreadable extension manifests (#4089)
Marsel Safin76e0d989aa8c
diff --git a/src/specify_cli/events.py b/src/specify_cli/events.pyindex ef298e8cb..ba0a4f636 100644--- a/src/specify_cli/events.py+++ b/src/specify_cli/events.py@@ -1091,7 +1091,7 @@ def collect_extension_events(project_root: Path) -> ResolvedEvents:continuetry:data = yaml.safe_load(ext_yml.read_text(encoding="utf-8")) or {}- except (UnicodeDecodeError, yaml.YAMLError):+ except (OSError, UnicodeDecodeError, yaml.YAMLError):continueif not isinstance(data, dict):continuediff --git a/tests/integrations/test_events.py b/tests/integrations/test_events.pyindex ba6deb12c..f5159c1d4 100644--- a/tests/integrations/test_events.py+++ b/tests/integrations/test_events.py@@ -188,6 +188,22 @@ class TestCollectExtensionEvents:assert collect_extension_events(tmp_path) == {}+ def test_unreadable_manifest_skipped(self, tmp_path, monkeypatch):+ ext_dir = tmp_path / ".specify" / "extensions" / "my-ext"+ ext_dir.mkdir(parents=True)+ manifest = ext_dir / "extension.yml"+ manifest.write_text("events: {}\n", encoding="utf-8")+ real_read_text = Path.read_text++ def unreadable(path, *args, **kwargs):+ if path == manifest:+ raise OSError("simulated read failure")+ return real_read_text(path, *args, **kwargs)++ monkeypatch.setattr(Path, "read_text", unreadable)++ 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 anobsolete command ref (e.g. my-ext.boot) is canonicalized