{"record":{"id":"9672d0bfa4dea38e","repo":"continuedev/continue","slug":"findandreplacemissingnewstring","errorCode":"FindAndReplaceMissingNewString","errorMessage":"${context}string new_string is required","messagePattern":"(.+?)string new_string is required","errorType":"validation","errorClass":"ContinueError","httpStatus":null,"severity":"error","filePath":"core/edit/searchAndReplace/findAndReplaceUtils.ts","lineNumber":24,"sourceCode":"/**\n * Validates a single edit operation\n */\nexport function validateSingleEdit(\n  oldString: unknown,\n  newString: unknown,\n  replaceAll: unknown,\n  index?: number,\n): { oldString: string; newString: string; replaceAll?: boolean } {\n  const context = index !== undefined ? `edit at index ${index}: ` : \"\";\n\n  if (oldString === undefined || typeof oldString !== \"string\") {\n    throw new ContinueError(\n      ContinueErrorReason.FindAndReplaceMissingOldString,\n      `${context}string old_string is required`,\n    );\n  }\n  if (newString === undefined || typeof newString !== \"string\") {\n    throw new ContinueError(\n      ContinueErrorReason.FindAndReplaceMissingNewString,\n      `${context}string new_string is required`,\n    );\n  }\n  if (oldString === newString) {\n    throw new ContinueError(\n      ContinueErrorReason.FindAndReplaceIdenticalOldAndNewStrings,\n      `${context}old_string and new_string must be different`,\n    );\n  }\n  if (replaceAll !== undefined && typeof replaceAll !== \"boolean\") {\n    throw new ContinueError(\n      ContinueErrorReason.FindAndReplaceInvalidReplaceAll,\n      `${context}replace_all must be a valid boolean`,\n    );\n  }\n  return { oldString, newString, replaceAll };\n}","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/continuedev/continue/blob/5522c6f44ca0ac3528b37244818fbfa39b5af470/core/edit/searchAndReplace/findAndReplaceUtils.ts#L6-L42","documentation":"validateSingleEdit also requires new_string to be present and a string; otherwise it throws ContinueError with code FindAndReplaceMissingNewString. Note the preceding check throws first, so this fires only when old_string was valid but new_string is missing/non-string.","triggerScenarios":"Edit payloads where oldString is a valid string but newString is undefined/null/non-string — commonly an LLM emitting a pure deletion without new_string or malformed JSON.","commonSituations":"LLM tool calls omitting new_string for deletions (should be empty string); dynamic payload construction; consumers assuming newString is optional.","solutions":["Always include newString (use \"\" for deletions)","Validate payloads with a schema/type guard before applying","Fix tool prompt/spec to mark new_string as required"],"exampleFix":"// before\napplyEdits([{ oldString: \"y\" }]);\n// after\napplyEdits([{ oldString: \"y\", newString: \"\" }]);","handlingStrategy":"type-guard","validationCode":"if (typeof edit.newString !== 'string') edit.newString = ''; // normalize deletions","typeGuard":"const isValidEdit = (e: unknown): e is { oldString: string; newString: string } =>\n  typeof (e as any)?.oldString === 'string' && typeof (e as any)?.newString === 'string';","tryCatchPattern":"catch (e) { if (e instanceof ContinueError && e.code === 'FindAndReplaceMissingNewString') { fill newString='' and revalidate; } }","preventionTips":["Treat new_string as required (empty string for deletions)","Mark both fields required in tool JSON schemas sent to the LLM"],"tags":["validation","edit","schema","llm-output"],"backgroundTag":"schema-validation-failed","analyzedSha":"5522c6f44ca0ac3528b37244818fbfa39b5af470","analyzedAt":"2026-08-27T11:28:54.683Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}