Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/specify_cli/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -1614,7 +1614,10 @@ def _build_opencode_plugin(
# S3: thread the per-handler timeout (seconds) to runEvent so the
# execFileSync cap and dispatcher arg match the configuration
# instead of a fixed 60000ms / 120s.
timeout_sec = int(cfg.get("timeout", 60))
try:
timeout_sec = int(cfg.get("timeout", 60))
except (TypeError, ValueError):
timeout_sec = 60
Comment thread
Quratulain-bilal marked this conversation as resolved.
if native.startswith("tool.execute."):
if matcher and matcher != "*":
tools = [t.strip().strip('"') for t in matcher.split("|")]
Expand Down
19 changes: 19 additions & 0 deletions tests/integrations/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,25 @@ def test_opencode_ts_plugin_escapes_metacharacters(self, tmp_path):
assert "runEvent('speckit.x" not in content
assert json.dumps("ed'it") in content

def test_opencode_non_numeric_timeout_uses_default(self, tmp_path):
"""A non-numeric timeout value in event config must not crash
_build_opencode_plugin; it should fall back to the default (60s)."""
integration = OpencodeIntegration()
manifest = MagicMock(spec=IntegrationManifest)
manifest.files = {}
manifest.record_file = MagicMock()
manifest.record_existing = MagicMock()

events = {
"pre_tool_use": [{"command": "speckit.tdd.validate", "timeout": "not-a-number"}],
}
# Must not raise TypeError or ValueError
install_integration_events(integration, tmp_path, manifest, events)
plugin_path = tmp_path / ".opencode/plugin/speckit-events.ts"
assert plugin_path.is_file()
content = plugin_path.read_text()
assert "speckit.tdd.validate" in content


# -- Command runner test (core execution) -----------------------------------

Expand Down