n8n-io/n8n · warning · UserError
Additional Model Request Fields must be valid JSON
Error message
Additional Model Request Fields must be valid JSON
What it means
Identical in spirit to error 682 but in the Bedrock Chat node: options.additionalModelRequestFields is a free-text JSON string; if it is non-empty, non-'{}', and fails jsonParse, a UserError (warning level) is thrown. Bedrock's Converse API accepts arbitrary model request overrides as a JSON object.
Source
Thrown at packages/@n8n/nodes-langchain/nodes/llms/LmChatAwsBedrock/LmChatAwsBedrock.node.ts:432
const guardrail = options.guardrail?.values;
if (guardrail?.guardrailIdentifier) {
modelConfig.guardrailConfig = {
guardrailIdentifier: guardrail.guardrailIdentifier,
// AWS requires a version whenever guardrailConfig is sent. The field may be blank,
// whitespace (e.g. from an expression), or absent (collection defaults only
// materialize on add); fall back to the working draft.
guardrailVersion: guardrail.guardrailVersion?.trim() || 'DRAFT',
...(guardrail.trace ? { trace: guardrail.trace } : {}),
};
}
const additionalFields = options.additionalModelRequestFields?.trim();
if (additionalFields && additionalFields !== '{}') {
let parsed: DocumentType;
try {
parsed = jsonParse<DocumentType>(additionalFields);
} catch {
throw new UserError('Additional Model Request Fields must be valid JSON', {
level: 'warning',
});
}
modelConfig.additionalModelRequestFields = parsed;
}
const model = new ChatBedrockConverse(modelConfig);
return {
response: model,
};
}
}
View on GitHub (pinned to 5ac6606e81)
Solutions
- Open 'Additional Model Request Fields' and paste valid JSON, e.g. {"inferenceConfig": {"maxTokens": 512}}.
- Run the string through a JSON linter.
- If templated, ensure the expression returns a valid JSON string or use {} / leave empty.
- Consult the Bedrock Converse API docs for the exact key names allowed.
Example fix
// before
options.additionalModelRequestFields = "inferenceConfig: {maxTokens: 512}"
// after
options.additionalModelRequestFields = "{\"inferenceConfig\": {\"maxTokens\": 512}}" Defensive patterns
Strategy: validation
Validate before calling
const raw = options.additionalModelRequestFields?.trim();
if (raw && raw !== '{}') {
try { JSON.parse(raw); }
catch (e) { throw new Error(`Fix JSON: ${(e as Error).message}`); }
} Type guard
const isJsonString = (s: string): boolean => { try { JSON.parse(s); return true; } catch { return false; } }; Try / catch
// Pre-validate at save; runtime catch only rewraps.
Prevention
- Validate the JSON field in the UI as the user types.
- Use {} or leave empty when no overrides are needed.
- Mirror the Bedrock Converse API key names in any examples.
When it happens
Trigger: User enters malformed JSON in 'Additional Model Request Fields' on the Bedrock Chat node — unquoted keys, trailing commas, smart quotes, or a templated expression resolving to invalid JSON.
Common situations: Pasting from Bedrock docs with single quotes; expression returning undefined; hand-editing; copy-paste with mangled characters.
Related errors
- Additional Model Request Fields must be valid JSON
- The value in the "Extra Body" field is not valid JSON
- Additional Model Request Fields must be a JSON object
- No model selected. Please choose a model.
- The value in the "Extra Body" field must be a JSON object
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/9a46001c1f3c2291.
Report an issue: GitHub.