{"record":{"id":"0ce48d96fbe224e6","repo":"n8n-io/n8n","slug":"replacements-must-be-an-array-of-old-str-new-str","errorCode":null,"errorMessage":"replacements must be an array of {old_str, new_str} objects. Example: {\"replacements\": [{\"old_str\": \"foo\", \"new_str\": \"bar\"}]}","messagePattern":"replacements must be an array of (.+?) objects\\. Example: (.+?)\\]\\}","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/@n8n/ai-utilities/src/utils/text-editor.ts","lineNumber":185,"sourceCode":"\t\t`  file:\\n${fileContext}`\n\t);\n}\n\nexport function parseStrReplacements(raw: unknown): StrReplacement[] {\n\tlet parsed = raw;\n\n\tif (typeof parsed === 'string') {\n\t\ttry {\n\t\t\tparsed = JSON.parse(parsed) as unknown;\n\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}","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/ai-utilities/src/utils/text-editor.ts#L167-L203","documentation":"Error \"replacements must be an array of {old_str, new_str} objects. Example: {\"replacements\": [{\"old_str\": \"foo\", \"new_str\": \"bar\"}]}\" thrown in n8n-io/n8n.","triggerScenarios":"Thrown at packages/@n8n/ai-utilities/src/utils/text-editor.ts:185 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-13T04:17:16.726Z"}