{"record":{"id":"2715de447bbc87f7","repo":"n8n-io/n8n","slug":"replacements-i-is-missing-a-valid-new-str-st","errorCode":null,"errorMessage":"replacements[${i}] is missing a valid \"new_str\" string. Each replacement must have {old_str: string, new_str: string}.","messagePattern":"replacements\\[(.+?)\\] is missing a valid \"new_str\" string\\. Each replacement must have (.+?)\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/@n8n/ai-utilities/src/utils/text-editor.ts","lineNumber":200,"sourceCode":"\t}\n\n\tif (!isUnknownArray(parsed)) {\n\t\tthrow new Error(\n\t\t\t'replacements must be an array of {old_str, new_str} objects. Example: {\"replacements\": [{\"old_str\": \"foo\", \"new_str\": \"bar\"}]}',\n\t\t);\n\t}\n\n\tconst replacements: StrReplacement[] = [];\n\n\tfor (let i = 0; i < parsed.length; i++) {\n\t\tconst item = parsed[i];\n\t\tif (!isObjectRecord(item) || typeof item.old_str !== 'string') {\n\t\t\tthrow new Error(\n\t\t\t\t`replacements[${i}] is missing a valid \"old_str\" string. Each replacement must have {old_str: string, new_str: string}.`,\n\t\t\t);\n\t\t}\n\t\tif (typeof item.new_str !== 'string') {\n\t\t\tthrow new Error(\n\t\t\t\t`replacements[${i}] is missing a valid \"new_str\" string. Each replacement must have {old_str: string, new_str: string}.`,\n\t\t\t);\n\t\t}\n\t\treplacements.push({ old_str: item.old_str, new_str: item.new_str });\n\t}\n\n\treturn replacements;\n}\n\nexport class TextEditorDocument {\n\tprivate text: string | null;\n\tprivate readonly options: TextEditorDocumentOptions;\n\n\tconstructor(options: TextEditorDocumentOptions = {}) {\n\t\tthis.text = options.initialText ?? null;\n\t\tthis.options = options;\n\t}\n","sourceCodeStart":182,"sourceCodeEnd":218,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/ai-utilities/src/utils/text-editor.ts#L182-L218","documentation":"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.","triggerScenarios":"Thrown at packages/@n8n/ai-utilities/src/utils/text-editor.ts:200 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}