Skip to content

Commit 4c6cbfc

Browse files
authored
fix(chat): Fix toolUse input is missing when parsing fails (aws#7001)
## Problem - ToolUse input is empty when parsing fails which breaks history ## Solution - Fix toolUse input is missing when parsing fails --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). - License: I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 2a33b10 commit 4c6cbfc

File tree

1 file changed

+10
-1
lines changed
  • packages/core/src/codewhispererChat/controllers/chat/messenger

1 file changed

+10
-1
lines changed

packages/core/src/codewhispererChat/controllers/chat/messenger/messenger.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,16 @@ export class Messenger {
269269
toolUse.toolUseId = cwChatEvent.toolUseEvent.toolUseId ?? ''
270270
toolUse.name = cwChatEvent.toolUseEvent.name ?? ''
271271
try {
272-
toolUse.input = JSON.parse(toolUseInput)
272+
try {
273+
toolUse.input = JSON.parse(toolUseInput)
274+
} catch (error: any) {
275+
getLogger().error(`JSON parse error for toolUseInput: ${toolUseInput}`)
276+
// set toolUse.input to the raw value
277+
toolUse.input = toolUseInput
278+
error.message = `Tool input has invalid JSON format: ${error.message}`
279+
// throw it out to allow the error to be handled in the catch block
280+
throw error
281+
}
273282
const availableToolsNames = (session.pairProgrammingModeOn ? tools : noWriteTools).map(
274283
(item) => item.toolSpecification?.name
275284
)

0 commit comments

Comments
 (0)