continuedev/continue · error · ContinueError
FindAndReplaceMissingOldString
FindAndReplaceMissingOldString
Error message
${context}string old_string is required What it means
validateSingleEdit enforces the search/replace edit schema: old_string must be present and a string. Missing or non-string old_string throws ContinueError with code FindAndReplaceMissingOldString (message prefixed with the multi-edit index when applicable).
Source
Thrown at core/edit/searchAndReplace/findAndReplaceUtils.ts:18
import { ContinueError, ContinueErrorReason } from "../../util/errors";
export const FOUND_MULTIPLE_FIND_STRINGS_ERROR =
"Either provide a more specific string with surrounding context to make it unique, or use replace_all=true to replace all occurrences.";
/**
* 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(View on GitHub (pinned to 5522c6f44c)
Solutions
- Validate edit payloads before calling apply (required string oldString)
- Fix the producer (prompt/tool schema) to always include old_string
- Log the index from the message to locate the offending edit in a multi-edit
Example fix
// before
applyEdits([{ newString: "x" }]);
// after
applyEdits([{ oldString: "y", newString: "x" }]); Defensive patterns
Strategy: type-guard
Validate before calling
edits.every(e => typeof e?.oldString === 'string' && typeof e?.newString === 'string') || failFast();
Type guard
const isValidEdit = (e: unknown): e is { oldString: string; newString: string; replaceAll?: boolean } =>
typeof (e as any)?.oldString === 'string' && typeof (e as any)?.newString === 'string'; Try / catch
catch (e) { if (e instanceof ContinueError && e.code === 'FindAndReplaceMissingOldString') { reportEditIndex(e.message); } } Prevention
- Schema-validate LLM/tool edit payloads before applying
- Use typed wrappers around raw JSON edit objects
When it happens
Trigger: Passing an edit object without oldString, or with oldString set to null/number (e.g. from unvalidated JSON or LLM output).
Common situations: LLM emits {new_string: ...} without old_string; user scripts build edit payloads from dynamic data where the field can be undefined; schema drift between versions.
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
- FindAndReplaceMissingNewString
- 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/b1f861d946ce6c1e.
Report an issue: GitHub.