{"record":{"id":"706844ad2ba0a3b2","repo":"n8n-io/n8n","slug":"parameter-parameter-name-is-not-a-valid-json","errorCode":null,"errorMessage":"Parameter ${parameter.name} is not a valid JSON: ${error.message}","messagePattern":"Parameter (.+?) is not a valid JSON: (.+?)","errorType":"exception","errorClass":"NodeOperationError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/nodes-langchain/nodes/tools/ToolHttpRequest/utils.ts","lineNumber":771,"sourceCode":"\t\t\t\t\t\t\t`Model did not provide parameter '${parameter.name}' which is required and must be present in the input`,\n\t\t\t\t\t\t\t{ itemIndex },\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tfor (const parameter of toolParameters) {\n\t\t\t\t\tlet argument = dataFromModel[parameter.name];\n\n\t\t\t\t\tif (\n\t\t\t\t\t\targument &&\n\t\t\t\t\t\tparameter.type === 'json' &&\n\t\t\t\t\t\t!['qsRaw', 'headersRaw', 'bodyRaw'].includes(parameter.key ?? '') &&\n\t\t\t\t\t\ttypeof argument !== 'object'\n\t\t\t\t\t) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\targument = jsonParse(String(argument));\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`Parameter ${parameter.name} is not a valid JSON: ${error.message}`,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\titemIndex,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (parameter.sendIn === 'path') {\n\t\t\t\t\t\targument = String(argument);\n\n\t\t\t\t\t\t//remove \" or ' from start or end\n\t\t\t\t\t\targument = argument.replace(/^['\"]+|['\"]+$/g, '');\n\n\t\t\t\t\t\toptions.url = options.url.replace(`{${parameter.name}}`, argument);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}","sourceCodeStart":753,"sourceCodeEnd":789,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/nodes-langchain/nodes/tools/ToolHttpRequest/utils.ts#L753-L789","documentation":"Thrown by configureToolFunction when a tool parameter of type 'json' receives a string argument (not already an object) that fails JSON.parse. This is distinct from the raw (qsRaw/headersRaw/bodyRaw) placeholders; it applies to individually-typed json parameters.","triggerScenarios":"The model supplies a malformed JSON string for a parameter declared as type 'json' (e.g. unquoted keys, single quotes, trailing comma); the model sends a plain string where a JSON object was expected.","commonSituations":"Complex nested JSON parameters that confuse the model; models that wrap JSON in backticks or prose; type set to 'json' but the model treats it as free text.","solutions":["Clarify in the parameter description that the value must be a valid JSON object string.","Change the parameter type to 'string' and parse it downstream in the sub-workflow.","Simplify the JSON shape the model must produce.","Use the structured-tool schema path so the framework coerces the value."],"exampleFix":"// before: parameter type 'json', model sends '{ name: \"x\" }' (unquoted keys) → throws\n// after: parameter type 'string', then parse in the workflow\n{ name: 'filter', type: 'string' }\n// in sub-workflow: JSON.parse($json.filter)","handlingStrategy":"try-catch","validationCode":"if (parameter.type === 'json' && typeof argument === 'string') {\n  try { argument = JSON.parse(argument); }\n  catch { argument = { value: argument }; /* graceful wrap */ }\n}","typeGuard":"function looksLikeJson(v: string): boolean {\n  const t = v.trim(); return (t.startsWith('{') && t.endsWith('}')) || (t.startsWith('[') && t.endsWith(']'));\n}","tryCatchPattern":"try { argument = jsonParse(String(argument)); }\ncatch (e) { /* degrade to string param or re-prompt */ }","preventionTips":["Prefer parameter type 'string' over 'json' unless structured data is required.","Document the expected JSON shape explicitly in the parameter description.","Let the structured-tool framework coerce JSON arguments."],"tags":["ai-tool","llm-input","json","http-request-tool","validation"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}