Fix #4664: Handle undefined error messages in apply_diff tool #4665
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes issue #4664 where the
apply_difftool returns an unhelpful 'undefined' error message when validation fails with non-Error objects or Error objects without a message property.Changes Made
Core Fix
presentAssistantMessage.ts: Updated the error handling logic in the tool validation catch block to properly handle cases whereerror.messageis undefinederror.messageis undefined, the code now usesJSON.stringify(serializeError(error))as a fallback to provide meaningful error informationTest Coverage
presentAssistantMessage.test.tswith tests covering:Technical Details
The bug occurred in
src/core/assistant-message/presentAssistantMessage.tsat lines 355-359 where the code was directly accessingerror.messagewithout checking if it exists:Testing
Impact
This fix ensures that users will always receive meaningful error messages instead of seeing 'undefined' when tool validation fails, improving the debugging experience and user experience overall.
Fixes #4664
Important
Fixes issue #4664 by improving error handling in
presentAssistantMessage.tsand adding comprehensive tests.presentAssistantMessage.tsto handle undefinederror.messageby usingJSON.stringify(serializeError(error)).presentAssistantMessage.test.tsto test error handling for various error types, including non-Error objects and undefined errors.list-files.tsby specifying directories to ignore in non-recursive searches.This description was created by
for 714ef08. You can customize this summary. It will automatically update as commits are pushed.