mirror of
https://github.com/github/spec-kit.git
synced 2026-08-15 14:02:04 +02:00
fix(events): ignore non-UTF-8 event overrides (#3897)
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:
@@ -737,8 +737,10 @@ def resolve_events(
|
||||
if override_file.exists():
|
||||
try:
|
||||
override = yaml.safe_load(override_file.read_text(encoding="utf-8")) or {}
|
||||
except yaml.YAMLError:
|
||||
logger.warning("Could not parse %s; ignoring override", override_file)
|
||||
except (OSError, UnicodeError, yaml.YAMLError):
|
||||
logger.warning(
|
||||
"Could not read or parse %s; ignoring override", override_file
|
||||
)
|
||||
override = {}
|
||||
integrations = override.get("integrations", {}) if isinstance(override, dict) else {}
|
||||
if isinstance(integrations, dict) and integration_key in integrations:
|
||||
|
||||
@@ -128,6 +128,23 @@ class TestResolveEvents:
|
||||
)
|
||||
assert result == {}
|
||||
|
||||
def test_unreadable_yaml_override_keeps_prior_layers(self, tmp_path):
|
||||
"""An unreadable override is ignored like malformed YAML."""
|
||||
override_file = tmp_path / ".specify" / "integration-events.yml"
|
||||
override_file.parent.mkdir(parents=True, exist_ok=True)
|
||||
override_file.write_bytes(b"\xff\xfe")
|
||||
|
||||
result = resolve_events(
|
||||
"claude",
|
||||
{"events": {"post_tool_use": {"command": "speckit.tdd.validate"}}},
|
||||
tmp_path,
|
||||
None,
|
||||
)
|
||||
|
||||
assert result == {
|
||||
"post_tool_use": [{"command": "speckit.tdd.validate"}]
|
||||
}
|
||||
|
||||
def test_no_config_no_events(self, tmp_path):
|
||||
"""Safe fallback with empty config/options."""
|
||||
result = resolve_events("claude", None, tmp_path, None)
|
||||
|
||||
Reference in New Issue
Block a user