{"record":{"id":"3f7aa580efb3c366","repo":"n8n-io/n8n","slug":"replacements-i-is-missing-a-valid-old-str-st","errorCode":null,"errorMessage":"replacements[${i}] is missing a valid \"old_str\" string. Each replacement must have {old_str: string, new_str: string}.","messagePattern":"replacements\\[(.+?)\\] is missing a valid \"old_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":195,"sourceCode":"\t\t} catch {\n\t\t\tthrow new Error(\n\t\t\t\t'replacements must be a JSON array of {old_str, new_str} objects, but received an invalid JSON string.',\n\t\t\t);\n\t\t}\n\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","sourceCodeStart":177,"sourceCodeEnd":213,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/ai-utilities/src/utils/text-editor.ts#L177-L213","documentation":"Error \"replacements[${i}] is missing a valid \"old_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:195 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-12T18:17:37.767Z"}