Skip to content

fix(write-file): use error.message instead of error.msg in catch block#467

Merged
jahooma merged 1 commit intoCodebuffAI:mainfrom
nil957:fix/write-file-error-message-typo
Mar 9, 2026
Merged

fix(write-file): use error.message instead of error.msg in catch block#467
jahooma merged 1 commit intoCodebuffAI:mainfrom
nil957:fix/write-file-error-message-typo

Conversation

@nil957
Copy link
Copy Markdown
Contributor

@nil957 nil957 commented Mar 9, 2026

Summary

Fixes a typo in the write-file tool handler where error.msg was used instead of error.message.

Problem

The error catch block in packages/agent-runtime/src/tools/handlers/tool/write-file.ts accesses error.msg instead of error.message, causing all non-string error details to be lost.

Standard JavaScript Error objects have a .message property, not .msg. When processFileBlock() throws a non-string error (which is the common case), error.msg evaluates to undefined, and the error message becomes:

Error: Failed to process the write_file block. undefined

This is the only occurrence of .msg in the codebase — all other error handling correctly uses .message.

Impact

When a file write operation fails with a non-string error, the actual error details are lost. Users and logs see "undefined" instead of the real error message, making debugging difficult.

Fix

- error: `Error: Failed to process the write_file block. ${typeof error === 'string' ? error : error.msg}`,
+ error: `Error: Failed to process the write_file block. ${typeof error === 'string' ? error : error.message}`,

Fixes #464

The error catch block accessed error.msg instead of error.message, causing
all non-string error details to be lost. Standard JavaScript Error objects
have a .message property, not .msg.

When processFileBlock() throws a non-string error, error.msg evaluates to
undefined, and the error message becomes:
  Error: Failed to process the write_file block. undefined

This is the only occurrence of .msg in the codebase - all other error handling
correctly uses .message.

Fixes CodebuffAI#464
@jahooma
Copy link
Copy Markdown
Contributor

jahooma commented Mar 9, 2026

Thanks!

@jahooma jahooma merged commit bfa5fbd into CodebuffAI:main Mar 9, 2026
reillyse pushed a commit to reillyse/codebuff that referenced this pull request Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: error.msg should be error.message in write-file handler catch block

2 participants