fix: add null guards for output.output in tool.execute.after hooks

Three hooks crashed with TypeError when MCP tools returned results where
output.output is undefined. Added type guards to all affected hooks:

- comment-checker/hook.ts: guard before toLowerCase()
- edit-error-recovery/hook.ts: guard before toLowerCase()
- task-resume-info/hook.ts: guard before startsWith()/includes()/trimEnd()
- Added test for undefined output.output in edit-error-recovery

Fixes #1746
This commit is contained in:
YeonGyu-Kim
2026-02-11 15:39:15 +09:00
parent 308ad1e98e
commit 8b44d3b7b5
7 changed files with 70 additions and 14 deletions
@@ -21,6 +21,17 @@ describe("createEditErrorRecoveryHook", () => {
metadata: {},
})
describe("#given output.output is undefined", () => {
//#when tool.execute.after is called
//#then should return without throwing
it("#then should not throw", async () => {
const input = createInput("Edit")
const output = { title: "Edit", output: undefined as unknown as string, metadata: {} }
await expect(hook["tool.execute.after"](input, output)).resolves.toBeUndefined()
})
})
describe("#given Edit tool with oldString/newString same error", () => {
describe("#when the error message is detected", () => {
it("#then should append the recovery reminder", async () => {