Skip to content

TypeError: output.output.toLowerCase() crashes on MCP tools with undefined output #1737

@pondzikk

Description

@pondzikk

Bug

oh-my-opencode@3.5.0 crashes with TypeError: undefined is not an object (evaluating 'output.output.toLowerCase') when certain MCP tools (e.g., websearch_web_search_exa, context7_query-docs) return results where output.output is undefined.

Root Cause

Two unguarded .toLowerCase() calls on output.output in dist/index.js:

  1. Line 26788tool.execute.after hook in the main tool execution handler:
const outputLower = output.output.toLowerCase(); // crashes if output.output is undefined
  1. Line 42754createEditErrorRecoveryHook:
const outputLower = output.output.toLowerCase(); // same issue

Expected Behavior

These hooks should safely handle cases where output.output is undefined or not a string (e.g., early return).

Suggested Fix

Add null/type guards before accessing output.output:

// Site 1 (main hook)
if (!output.output || typeof output.output !== "string") {
  return;
}
const outputLower = output.output.toLowerCase();

// Site 2 (edit error recovery hook)  
if (!output.output || typeof output.output !== "string")
  return;
const outputLower = output.output.toLowerCase();

Reproduction

  1. Install oh-my-opencode@3.5.0 with any MCP tool that returns non-string output (websearch_web_search_exa, context7, etc.)
  2. Use the MCP tool in a session
  3. Observe TypeError in the console

Environment

  • OpenCode: v1.1.55
  • oh-my-opencode: v3.5.0
  • OS: Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions