{"record":{"id":"5cd258058a8a3cb5","repo":"n8n-io/n8n","slug":"could-not-replace-placeholders-in-key-error","errorCode":null,"errorMessage":"Could not replace placeholders in ${key}: ${error.message}","messagePattern":"Could not replace placeholders in (.+?): (.+?)","errorType":"exception","errorClass":"NodeOperationError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/nodes-langchain/nodes/tools/ToolHttpRequest/utils.ts","lineNumber":841,"sourceCode":"\t\t\t\t\t\t\t\t`{${parameter.name}}`,\n\t\t\t\t\t\t\t\tString(argument),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tset(options, [parameter.sendIn, parameter.key], requestOptionsValue);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tset(options, [parameter.sendIn, parameter.name], argument);\n\t\t\t\t}\n\n\t\t\t\tfor (const [key, value] of Object.entries(clonedRawRequestOptions)) {\n\t\t\t\t\tif (value) {\n\t\t\t\t\t\tlet parsedValue;\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tparsedValue = jsonParse<IDataObject>(value, { repairJSON: true });\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\tthrow new NodeOperationError(\n\t\t\t\t\t\t\t\tctx.getNode(),\n\t\t\t\t\t\t\t\t`Could not replace placeholders in ${key}: ${error.message}`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\toptions[key as 'qs' | 'headers' | 'body'] = parsedValue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (options) {\n\t\t\t\toptions.url = encodeURI(options.url);\n\n\t\t\t\tif (options.headers && !Object.keys(options.headers).length) {\n\t\t\t\t\tdelete options.headers;\n\t\t\t\t}\n\t\t\t\tif (options.qs && !Object.keys(options.qs).length) {\n\t\t\t\t\tdelete options.qs;\n\t\t\t\t}","sourceCodeStart":823,"sourceCodeEnd":859,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/nodes-langchain/nodes/tools/ToolHttpRequest/utils.ts#L823-L859","documentation":"Thrown by configureToolFunction when parsing a raw request option block (qs, headers, or body entered as a JSON string with placeholders) and jsonParse with repairJSON:true still fails. The placeholder substitution relies on a parseable JSON skeleton, so an unrepairable skeleton aborts.","triggerScenarios":"The user enters a raw JSON block in the node (Query / Headers / Body tab using 'JSON' input mode) with severe syntax errors — mismatched braces, stray characters, or unbalanced brackets that the repair heuristic cannot fix.","commonSituations":"Hand-editing the raw JSON and introducing a typo; copy-pasting from a source that mangled quotes; partial edits leaving dangling commas or unclosed objects.","solutions":["Open the node's raw JSON input for the named key (the message tells you which: qs/headers/body) and paste it into a JSON linter; fix all syntax errors.","Switch that input from 'JSON' mode to 'Keypair' mode so the UI guarantees valid structure.","Remove the offending block and re-enter it field by field.","Validate the JSON in an external tool before pasting back."],"exampleFix":"// before (headers raw, broken):\n{ \"Authorization\": \"Bearer {token\", \"Accept\": \"application/json\" }\n// (missing closing brace in placeholder)\n\n// after:\n{ \"Authorization\": \"Bearer {token}\", \"Accept\": \"application/json\" }","handlingStrategy":"validation","validationCode":"for (const [key, value] of Object.entries(rawRequestOptions)) {\n  if (value) {\n    try { JSON.parse(value); }\n    catch { throw new Error(`Fix the raw JSON for '${key}' before running: ${value}`); }\n  }\n}","typeGuard":"function isValidJsonString(s: string): boolean {\n  try { JSON.parse(s); return true; } catch { return false; }\n}","tryCatchPattern":"try { parsedValue = jsonParse<IDataObject>(value, { repairJSON: true }); }\ncatch (e) { /* surface a clear 'fix raw JSON for key X' message */ }","preventionTips":["Always lint raw JSON blocks in the node UI before saving.","Prefer 'Keypair' input mode over 'JSON' to guarantee validity.","Re-validate raw JSON whenever placeholders are added or renamed."],"tags":["http-request-tool","json","configuration","ai-tool"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}