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:
@@ -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 () => {
|
||||
|
||||
Reference in New Issue
Block a user