-
Notifications
You must be signed in to change notification settings - Fork 2.3k
[Bug]: Fix TypeError crash in tool.execute.after hooks when output.output is undefined #1723
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
Multiple tool.execute.after hooks crash with TypeError when MCP tools return responses where output.output is undefined/non-string. Add `if (typeof output.output !== 'string') return` guard to: - comment-checker/hook.ts - edit-error-recovery/hook.ts - task-resume-info/hook.ts This matches the existing pattern in tool-output-truncator.ts (line 42). Fixes crashes seen in v3.4.0 and v3.4.1 when using MCP server tools. Related: code-yeongyu#1720, code-yeongyu#1035
|
All contributors have signed the CLA. Thank you! ✅ |
There was a problem hiding this 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: Only adds type checks to prevent errors, no regressions introduced, aligns with criteria for safe changes.
|
I have read the CLA Document and I hereby sign the CLA |
|
recheck |
|
I have read the CLA Document and I hereby sign the CLA |
|
recheck |
Problem
Multiple
tool.execute.afterhooks crash withTypeError: undefined is not an object (evaluating 'output.output.toLowerCase')when MCP tools return responses whereoutput.outputisundefinedor not a string.This affects v3.4.0 and was also present in v3.4.1 (which was yanked via #1720).
Error
Reproduction
Any MCP tool that returns a response where
output.outputisundefinedinstead of a string will trigger this crash. This commonly happens with:outputfieldRoot Cause
Three
tool.execute.afterhooks accessoutput.outputwithout checking if it's a string first:src/hooks/comment-checker/hook.ts(line 95):src/hooks/edit-error-recovery/hook.ts(line 47):src/hooks/task-resume-info/hook.ts(lines 24-25, 31):Fix
Added
if (typeof output.output !== 'string') returnas an early guard in all three affected hooks, matching the existing pattern already used insrc/hooks/tool-output-truncator.ts(line 42):This is the minimal, consistent fix — it follows the established convention in the codebase and gracefully handles the case where
output.outputisundefined,null, or any non-string type.Files Changed
src/hooks/comment-checker/hook.tsoutput.output.toLowerCase()src/hooks/edit-error-recovery/hook.tsoutput.output.toLowerCase()src/hooks/task-resume-info/hook.tsoutput.output.startsWith()Verification
bun run typecheck— passes clean (0 errors)bun run build— passes cleanRelated Issues
TypeErrorclassoutput.outputcrash (closed)Summary by cubic
Fixes a TypeError crash in tool.execute.after hooks when MCP tools return non-string or undefined output.output. Adds a simple guard so structured or metadata-only responses no longer break execution.
Written for commit 5a2075a. Summary will update on new commits.