n8n-io/n8n · error · Error
replacements[${i}] is missing a valid "new_str" string. Each
Error message
replacements[${i}] is missing a valid "new_str" string. Each replacement must have {old_str: string, new_str: string}. What it means
Error "replacements[${i}] is missing a valid "new_str" string. Each replacement must have {old_str: string, new_str: string}." thrown in n8n-io/n8n.
Source
Thrown at packages/@n8n/ai-utilities/src/utils/text-editor.ts:200
}
if (!isUnknownArray(parsed)) {
throw new Error(
'replacements must be an array of {old_str, new_str} objects. Example: {"replacements": [{"old_str": "foo", "new_str": "bar"}]}',
);
}
const replacements: StrReplacement[] = [];
for (let i = 0; i < parsed.length; i++) {
const item = parsed[i];
if (!isObjectRecord(item) || typeof item.old_str !== 'string') {
throw new Error(
`replacements[${i}] is missing a valid "old_str" string. Each replacement must have {old_str: string, new_str: string}.`,
);
}
if (typeof item.new_str !== 'string') {
throw new Error(
`replacements[${i}] is missing a valid "new_str" string. Each replacement must have {old_str: string, new_str: string}.`,
);
}
replacements.push({ old_str: item.old_str, new_str: item.new_str });
}
return replacements;
}
export class TextEditorDocument {
private text: string | null;
private readonly options: TextEditorDocumentOptions;
constructor(options: TextEditorDocumentOptions = {}) {
this.text = options.initialText ?? null;
this.options = options;
}
View on GitHub (pinned to 5ac6606e81)
When it happens
Trigger: Thrown at packages/@n8n/ai-utilities/src/utils/text-editor.ts:200 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/2715de447bbc87f7.
Report an issue: GitHub.