{"record":{"id":"891ebe8475b17497","repo":"n8n-io/n8n","slug":"the-value-in-the-extra-body-field-is-not-valid-j","errorCode":null,"errorMessage":"The value in the \"Extra Body\" field is not valid JSON","messagePattern":"The value in the \"Extra Body\" field is not valid JSON","errorType":"exception","errorClass":"NodeOperationError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/nodes-langchain/nodes/llms/LMChatOpenAi/LmChatOpenAi.node.ts","lineNumber":815,"sourceCode":"\n\t\t// Extra options to send to OpenAI, that are not directly supported by LangChain\n\t\tconst modelKwargs: Record<string, unknown> = {};\n\t\tif (responsesApiEnabled) {\n\t\t\tconst kwargs = prepareAdditionalResponsesParams(options);\n\t\t\tObject.assign(modelKwargs, kwargs);\n\t\t} else {\n\t\t\tif (options.responseFormat) modelKwargs.response_format = { type: options.responseFormat };\n\t\t\tif (options.reasoningEffort && ['low', 'medium', 'high'].includes(options.reasoningEffort)) {\n\t\t\t\tmodelKwargs.reasoning_effort = options.reasoningEffort;\n\t\t\t}\n\t\t}\n\n\t\tif (options.extraBody) {\n\t\t\tlet extraBody: Record<string, unknown>;\n\t\t\ttry {\n\t\t\t\textraBody = jsonParse<Record<string, unknown>>(options.extraBody);\n\t\t\t} catch (error) {\n\t\t\t\tthrow new NodeOperationError(\n\t\t\t\t\tthis.getNode(),\n\t\t\t\t\t'The value in the \"Extra Body\" field is not valid JSON',\n\t\t\t\t\t{ itemIndex, description: error instanceof Error ? error.message : String(error) },\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (!isPlainObject(extraBody)) {\n\t\t\t\tthrow new NodeOperationError(\n\t\t\t\t\tthis.getNode(),\n\t\t\t\t\t'The value in the \"Extra Body\" field must be a JSON object',\n\t\t\t\t\t{ itemIndex },\n\t\t\t\t);\n\t\t\t}\n\t\t\tObject.assign(modelKwargs, extraBody);\n\t\t}\n\n\t\tconst includedOptions = pick(options, [\n\t\t\t'frequencyPenalty',\n\t\t\t'maxTokens',","sourceCodeStart":797,"sourceCodeEnd":833,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/nodes-langchain/nodes/llms/LMChatOpenAi/LmChatOpenAi.node.ts#L797-L833","documentation":"Thrown by the OpenAI Chat node when options.extraBody is set but jsonParse() throws. The 'Extra Body' option lets users inject arbitrary keys into the OpenAI request body; it must be valid JSON, so the NodeOperationError carries the parse error message in its description for context.","triggerScenarios":"options.extraBody contains malformed JSON — unquoted keys, trailing commas, a templated value that produced 'undefined', smart quotes, or a paste from docs with comments.","commonSituations":"Pasting examples with JavaScript-style keys; expression that returns a non-JSON string; copy-paste from a chat that mangled quotes; user typing 'temperature: 0.5' instead of '{\"temperature\": 0.5}'.","solutions":["Open 'Extra Body' and paste valid JSON, e.g. {\"user\": \"abc-123\"}.","Run the value through a JSON linter before saving.","If templating, ensure the expression returns a JSON string or use n8n's object parameters directly.","Leave the field empty if no extra keys are required."],"exampleFix":"// before\noptions.extraBody = \"temperature: 0.5\"\n// after\noptions.extraBody = \"{\\\"temperature\\\": 0.5}\"","handlingStrategy":"validation","validationCode":"if (options.extraBody) {\n  try { JSON.parse(options.extraBody); }\n  catch (e) { throw new Error(`'Extra Body' is not valid JSON: ${(e as Error).message}`); }\n}","typeGuard":"const isParsableJson = (s: string): boolean => { try { JSON.parse(s); return true; } catch { return false; } };","tryCatchPattern":"// Pre-validate at save time; runtime catch only rewraps for context.","preventionTips":["Validate the Extra Body field with a JSON linter in the UI.","Use n8n's built-in JSON parameter type instead of a free-text field.","Prefer empty value when no extra keys are needed."],"tags":["openai","llm","json","configuration","user-input"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}