Skip to content

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

@dsurchisactive

Description

@dsurchisactive

Description

The error catch block in the write_file tool handler accesses error.msg instead of error.message, causing all non-string error details to be lost.

Root Cause

In packages/agent-runtime/src/tools/handlers/tool/write-file.ts (line 142):

.catch((error) => {
  // ...
  return {
    tool: 'write_file' as const,
    path,
    error: `Error: Failed to process the write_file block. ${typeof error === 'string' ? error : error.msg}`,
  }
})

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.

Suggested Fix

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions