Skip to content

NoChangeError message has broken ToolName interpolation and typo #4671

@ShehabSherif0

Description

@ShehabSherif0

Bug

In src/extension/tools/node/editFileToolUtils.tsx (line 671), the NoChangeError message uses single quotes for a string containing ${ToolName.ReadFile}:

throw new NoChangeError(
    'Original and edited file match exactly. Failed to apply edit. Use the ${ToolName.ReadFile} tool to re-read the file and and determine the correct edit.',
    filePath
);

Two issues on the same line

1. Broken template interpolation: Single-quoted strings do not support ${...} interpolation in JavaScript/TypeScript. The model literally receives the text ${ToolName.ReadFile} instead of read_file. Additionally, ToolName is not imported in this file, so even changing to backticks alone would cause a ReferenceError.

2. Doubled word typo: "re-read the file and and determine" has a duplicate "and".

What the model sees today

String replacement failed: Original and edited file match exactly. Failed to apply edit. Use the ${ToolName.ReadFile} tool to re-read the file and and determine the correct edit.

What it should see

String replacement failed: Original and edited file match exactly. Failed to apply edit. Use the read_file tool to re-read the file and determine the correct edit.

Impact

This error triggers when replace_string_in_file produces no actual change (e.g., the model's edit matched via fuzzy/whitespace matching but the replacement yielded identical content). The garbled tool name prevents the model from following the recovery instruction to re-read the file, degrading agent mode's ability to self-correct on failed edits.

Proof

const ToolName = { ReadFile: 'read_file' };
const bugged = 'Use the ${ToolName.ReadFile} tool';
const fixed  = `Use the ${ToolName.ReadFile} tool`;
console.log('BUGGED:', bugged); // "Use the ${ToolName.ReadFile} tool"
console.log('FIXED: ', fixed);  // "Use the read_file tool"

Fix

  1. Add import { ToolName } from '../common/toolNames';
  2. Change single quotes to backticks
  3. Fix and and to and

Every other usage of ToolName.* in the codebase uses backtick template literals correctly. This is the only instance using single quotes.

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