Skip to content

Commit 70d40fb

Browse files
fix: narrow exception in invoke separator resolution and add regression test
Narrow 'except Exception' to 'except (ImportError, ValueError, KeyError)' in register_commands() invoke separator resolution. Add regression test that verifies TypeError propagates instead of being silently swallowed.
1 parent 36cb7e3 commit 70d40fb

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

src/specify_cli/agents.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,8 @@ def register_commands(
679679
_integ = get_integration(agent_name)
680680
if _integ is not None:
681681
_sep = _integ.invoke_separator_for_mode(registrar_writes_skills)
682-
except Exception:
682+
except (ImportError, ValueError, KeyError):
683+
pass
683684
pass
684685
_prefix = get_invocation_prefix(agent_name, registrar_writes_skills)
685686

tests/test_post_process.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,3 +274,29 @@ def test_cline_transforms_applied_via_registrar(
274274
# _rewrite_handoff_references rewrote the dotted agent handoff
275275
assert "agent: speckit-foo" in content
276276
assert "agent: speckit.foo" not in content
277+
278+
279+
def test_register_commands_propagates_programming_errors(tmp_path):
280+
"""Regression: narrowed exception must not swallow TypeError/AttributeError.
281+
282+
The invoke separator resolution narrowed from bare 'except Exception' to
283+
'except (ImportError, ValueError, KeyError)'. Programming errors like
284+
TypeError must propagate instead of being silently swallowed.
285+
"""
286+
registrar = CommandRegistrar()
287+
commands = [{"name": "test.cmd", "file": "commands/test.md"}]
288+
289+
ext_dir = tmp_path / "ext"
290+
ext_dir.mkdir()
291+
292+
def _broken_get_integration(name):
293+
raise TypeError("intentional programming error")
294+
295+
import specify_cli.integrations as integ_mod
296+
original = integ_mod.get_integration
297+
integ_mod.get_integration = _broken_get_integration
298+
try:
299+
with pytest.raises(TypeError, match="intentional programming error"):
300+
registrar.register_commands("bob", commands, "ext", ext_dir, tmp_path)
301+
finally:
302+
integ_mod.get_integration = original

0 commit comments

Comments
 (0)