continuedev/continue · error · ContinueError
FindAndReplaceMissingNewString
FindAndReplaceMissingNewString
Error message
${context}string new_string is required What it means
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.
Source
Thrown at core/edit/searchAndReplace/findAndReplaceUtils.ts:24
/**
* Validates a single edit operation
*/
export function validateSingleEdit(
oldString: unknown,
newString: unknown,
replaceAll: unknown,
index?: number,
): { oldString: string; newString: string; replaceAll?: boolean } {
const context = index !== undefined ? `edit at index ${index}: ` : "";
if (oldString === undefined || typeof oldString !== "string") {
throw new ContinueError(
ContinueErrorReason.FindAndReplaceMissingOldString,
`${context}string old_string is required`,
);
}
if (newString === undefined || typeof newString !== "string") {
throw new ContinueError(
ContinueErrorReason.FindAndReplaceMissingNewString,
`${context}string new_string is required`,
);
}
if (oldString === newString) {
throw new ContinueError(
ContinueErrorReason.FindAndReplaceIdenticalOldAndNewStrings,
`${context}old_string and new_string must be different`,
);
}
if (replaceAll !== undefined && typeof replaceAll !== "boolean") {
throw new ContinueError(
ContinueErrorReason.FindAndReplaceInvalidReplaceAll,
`${context}replace_all must be a valid boolean`,
);
}
return { oldString, newString, replaceAll };
}View on GitHub (pinned to 5522c6f44c)
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
Example fix
// before
applyEdits([{ oldString: "y" }]);
// after
applyEdits([{ oldString: "y", newString: "" }]); Defensive patterns
Strategy: type-guard
Validate before calling
if (typeof edit.newString !== 'string') edit.newString = ''; // normalize deletions
Type guard
const isValidEdit = (e: unknown): e is { oldString: string; newString: string } =>
typeof (e as any)?.oldString === 'string' && typeof (e as any)?.newString === 'string'; Try / catch
catch (e) { if (e instanceof ContinueError && e.code === 'FindAndReplaceMissingNewString') { fill newString='' and revalidate; } } Prevention
- Treat new_string as required (empty string for deletions)
- Mark both fields required in tool JSON schemas sent to the LLM
When it happens
Trigger: 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.
Common situations: LLM tool calls omitting new_string for deletions (should be empty string); dynamic payload construction; consumers assuming newString is optional.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- FindAndReplaceMissingOldString
- Hunk could not be applied cleanly to source code.
- FindAndReplaceIdenticalOldAndNewStrings
- Failed to parse config: ${formatZodError(e)}
- No edit snippet provided.
AI-assisted analysis of continuedev/continue@5522c6f44c (2026-08-27).
Data as JSON: /api/errors/9672d0bfa4dea38e.
Report an issue: GitHub.