Skip to content

fix: add ValueError guard for timeout in _build_opencode_plugin - #3973

Open
Quratulain-bilal wants to merge 3 commits into
github:mainfrom
Quratulain-bilal:fix/events-timeout-int-guard
Open

Quratulain-bilal wants to merge 3 commits into
github:mainfrom
Quratulain-bilal:fix/events-timeout-int-guard

Conversation

@Quratulain-bilal

Copy link
Copy Markdown
Contributor

Problem

int(cfg.get('timeout', 60)) crashes with an unhandled ValueError when a user provides a non-numeric timeout value in event configuration. Two other call sites in the same file already handle this gracefully with ry/except (TypeError, ValueError).

Fix

Added the same ry/except guard, making the third call site consistent.

int(cfg.get('timeout', 60)) would crash on non-numeric user-provided
timeout values. Two other call sites in the same file already handle
this with try/except (TypeError, ValueError). This makes the third
call site consistent.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds defensive timeout parsing for OpenCode event plugins.

Changes:

  • Falls back to 60 seconds when timeout conversion raises TypeError or ValueError.
Show a summary per file
File Description
src/specify_cli/events.py Guards OpenCode timeout conversion.

Review details

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread src/specify_cli/events.py
…plugin

Verify that a non-numeric timeout value (e.g. 'not-a-number') does not
crash with TypeError/ValueError and falls back to the default 60s.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The regression test must assert the complete generated runEvent call uses the 60-second fallback.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Balanced

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

@mnriem mnriem left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address Copilot feedback

…d test

Addresses Copilot feedback: the regression test now verifies the exact
runEvent() call uses the 60-second default, not just that the handler
name is present.

Assisted-by: GitHub Copilot (autonomous)
@Quratulain-bilal

Copy link
Copy Markdown
Contributor Author

Hi @mnriem — I've addressed Copilot's feedback: the regression test now asserts the complete
unEvent() call with the 60-second fallback, not just the handler name. Ready for re-review when you get a chance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants