Skip to content

Conversation

@materializerx
Copy link

@materializerx materializerx commented Feb 10, 2026

Summary

  • Add null/type guards for output.output in 3 hooks that crash when it's undefined
  • Fixes TypeError: undefined is not an object (evaluating 'output.output.toLowerCase') for external MCP tools

Problem

Three tool.execute.after hooks call string methods on output.output without checking if it's defined:

Hook Crash site
comment-checker/hook.ts output.output.toLowerCase() (line 95)
edit-error-recovery/hook.ts output.output.toLowerCase() (line 47)
task-resume-info/hook.ts output.output.startsWith() (line 24)

When OpenCode passes undefined for output.output (observed with external MCP tools), all three crash with TypeError.

Fix

Added if (!output.output || typeof output.output !== "string") return guard before accessing output.output methods. This matches the existing pattern in tool-output-truncator.ts (line 42) which already had this guard.

Context


Summary by cubic

Guard output.output against undefined in tool.execute.after hooks to prevent crashes with external MCP tools. Fixes #1720.

  • Bug Fixes
    • Add null/type checks before calling string methods in comment-checker, edit-error-recovery, and task-resume-info hooks.
    • Early-return when output.output is missing or not a string (log skip in comment-checker), matching tool-output-truncator behavior.

Written for commit 290cf3d. Summary will update on new commits.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 10, 2026

All contributors have signed the CLA. Thank you! ✅
Posted by the CLA Assistant Lite bot.

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 3 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Auto-approved: Minor additions of type checks to prevent errors, no regressions detected, aligns with criteria for safe changes.

@materializerx
Copy link
Author

I have read the CLA Document and I hereby sign the CLA

@materializerx
Copy link
Author

recheck

Three hooks crash with TypeError when output.output is undefined for
external MCP tool results. Add null/type guards before calling string
methods (.toLowerCase(), .startsWith(), .includes()) on output.output.

Affected hooks:
- comment-checker: output.output.toLowerCase() at line 95
- edit-error-recovery: output.output.toLowerCase() at line 47
- task-resume-info: output.output.startsWith() at line 24

The tool-output-truncator hook already had this guard (typeof check at
line 42), so this aligns the other hooks with that pattern.

Fixes code-yeongyu#1720
@materializerx materializerx force-pushed the fix/guard-output-undefined-in-hooks branch from d9b9050 to 290cf3d Compare February 10, 2026 15:21
@materializerx
Copy link
Author

I have read the CLA Document and I hereby sign the CLA

github-actions bot added a commit that referenced this pull request Feb 10, 2026
marlon-costa-dc pushed a commit to marlon-costa-dc/oh-my-opencode that referenced this pull request Feb 10, 2026
marlon-costa-dc added a commit to marlon-costa-dc/oh-my-opencode that referenced this pull request Feb 10, 2026
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.

FYI: v3.4.1 broke all external MCP tools (published & yanked)

1 participant