n8n-io/n8n · error · NodeOperationError
The value in the "Extra Body" field is not valid JSON
Error message
The value in the "Extra Body" field is not valid JSON
What it means
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.
Source
Thrown at packages/@n8n/nodes-langchain/nodes/llms/LMChatOpenAi/LmChatOpenAi.node.ts:815
// Extra options to send to OpenAI, that are not directly supported by LangChain
const modelKwargs: Record<string, unknown> = {};
if (responsesApiEnabled) {
const kwargs = prepareAdditionalResponsesParams(options);
Object.assign(modelKwargs, kwargs);
} else {
if (options.responseFormat) modelKwargs.response_format = { type: options.responseFormat };
if (options.reasoningEffort && ['low', 'medium', 'high'].includes(options.reasoningEffort)) {
modelKwargs.reasoning_effort = options.reasoningEffort;
}
}
if (options.extraBody) {
let extraBody: Record<string, unknown>;
try {
extraBody = jsonParse<Record<string, unknown>>(options.extraBody);
} catch (error) {
throw new NodeOperationError(
this.getNode(),
'The value in the "Extra Body" field is not valid JSON',
{ itemIndex, description: error instanceof Error ? error.message : String(error) },
);
}
if (!isPlainObject(extraBody)) {
throw new NodeOperationError(
this.getNode(),
'The value in the "Extra Body" field must be a JSON object',
{ itemIndex },
);
}
Object.assign(modelKwargs, extraBody);
}
const includedOptions = pick(options, [
'frequencyPenalty',
'maxTokens',View on GitHub (pinned to 5ac6606e81)
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.
Example fix
// before
options.extraBody = "temperature: 0.5"
// after
options.extraBody = "{\"temperature\": 0.5}" Defensive patterns
Strategy: validation
Validate before calling
if (options.extraBody) {
try { JSON.parse(options.extraBody); }
catch (e) { throw new Error(`'Extra Body' is not valid JSON: ${(e as Error).message}`); }
} Type guard
const isParsableJson = (s: string): boolean => { try { JSON.parse(s); return true; } catch { return false; } }; Try / catch
// Pre-validate at save time; runtime catch only rewraps for context.
Prevention
- 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.
When it happens
Trigger: options.extraBody contains malformed JSON — unquoted keys, trailing commas, a templated value that produced 'undefined', smart quotes, or a paste from docs with comments.
Common situations: 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}'.
Related errors
- The value in the "Extra Body" field must be a JSON object
- Additional Model Request Fields must be valid JSON
- Additional Model Request Fields must be valid JSON
- No model selected. Please choose a model.
- Invalid authentication method
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/891ebe8475b17497.
Report an issue: GitHub.