Skip to content

Commit 015c0d8

Browse files
marcelsafinCopilot
andcommitted
fix(events): skip unreadable extension manifests
Assisted-by: GitHub Copilot (model: gpt-5.6-sol, autonomous) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 197dde6 commit 015c0d8

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

src/specify_cli/events.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1014,7 +1014,7 @@ def collect_extension_events(project_root: Path) -> ResolvedEvents:
10141014
continue
10151015
try:
10161016
data = yaml.safe_load(ext_yml.read_text(encoding="utf-8")) or {}
1017-
except (UnicodeDecodeError, yaml.YAMLError):
1017+
except (OSError, UnicodeDecodeError, yaml.YAMLError):
10181018
continue
10191019
if not isinstance(data, dict):
10201020
continue

tests/integrations/test_events.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,22 @@ def test_non_utf8_manifest_skipped(self, tmp_path):
188188

189189
assert collect_extension_events(tmp_path) == {}
190190

191+
def test_unreadable_manifest_skipped(self, tmp_path, monkeypatch):
192+
ext_dir = tmp_path / ".specify" / "extensions" / "my-ext"
193+
ext_dir.mkdir(parents=True)
194+
manifest = ext_dir / "extension.yml"
195+
manifest.write_text("events: {}\n", encoding="utf-8")
196+
real_read_text = Path.read_text
197+
198+
def unreadable(path, *args, **kwargs):
199+
if path == manifest:
200+
raise OSError("simulated read failure")
201+
return real_read_text(path, *args, **kwargs)
202+
203+
monkeypatch.setattr(Path, "read_text", unreadable)
204+
205+
assert collect_extension_events(tmp_path) == {}
206+
191207
def test_event_command_ref_canonicalized_via_manifest(self, tmp_path):
192208
"""R1: events are read from a validated ExtensionManifest, so an
193209
obsolete command ref (e.g. my-ext.boot) is canonicalized

0 commit comments

Comments
 (0)