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

A UserError (level: warning) thrown while parsing the 'Additional Model Request Fields' option on the AWS Bedrock Embeddings node. The field is a free-text JSON string; jsonParse() throws when it is not valid JSON, and the catch converts that into an actionable message. Severity is 'warning' so the UI surfaces it without aborting the whole execution batch.

Source

Thrown at packages/@n8n/nodes-langchain/nodes/embeddings/EmbeddingsAwsBedrock/EmbeddingsAwsBedrock.node.ts:156

		const region = resolveBedrockRegion(modelName, credentialRegion);

		const client = createBedrockRuntimeClient({
			region,
			credentials,
			bedrockRuntimeEndpoint,
			maxRetries: options.maxRetries,
			timeout: options.timeout,
		});

		let additionalModelRequestFields: Record<string, unknown> | undefined;
		const additionalFields = options.additionalModelRequestFields?.trim();
		if (additionalFields && additionalFields !== '{}') {
			let parsed: unknown;
			try {
				parsed = jsonParse(additionalFields);
			} catch {
				throw new UserError('Additional Model Request Fields must be valid JSON', {
					level: 'warning',
				});
			}
			if (!isJsonObject(parsed)) {
				throw new UserError('Additional Model Request Fields must be a JSON object', {
					level: 'warning',
				});
			}
			additionalModelRequestFields = parsed;
		}

		const embeddings = new BedrockInvokeModelEmbeddings({
			client,
			model: modelName,
			additionalModelRequestFields,
		});

		return {

View on GitHub (pinned to 5ac6606e81)

Solutions

  1. Open the 'Additional Model Request Fields' option and paste minimal valid JSON, e.g. {"dimensions": 256}.
  2. Validate the string in a JSON linter (jsonlint.com) before saving.
  3. If the value is templated, wrap it so it always emits valid JSON or leave the field empty when no overrides are needed.
  4. Use {} or leave blank — the code skips parsing entirely when the trimmed value is empty or '{}'.

Example fix

// before
options.additionalModelRequestFields = "dimensions: 256"
// after
options.additionalModelRequestFields = "{\"dimensions\": 256}"
Defensive patterns

Strategy: validation

Validate before calling

const raw = options.additionalModelRequestFields?.trim();
if (raw && raw !== '{}') {
  let parsed;
  try { parsed = JSON.parse(raw); }
  catch (e) {
    // show inline UI validation; do not let execution reach supplyData
    throw new Error(`Fix JSON in 'Additional Model Request Fields': ${(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 UI/save time; runtime catch only rewraps into the UserError.

Prevention

When it happens

Trigger: options.additionalModelRequestFields is a non-empty, non-'{}' string that fails JSON.parse — unquoted keys, trailing commas, smart quotes pasted from docs, a single value like 'dimensions: 256', or a templating expression that resolved to invalid JSON at runtime.

Common situations: Pasting examples from Bedrock docs that use single quotes; using {{ $json.foo }} that returned undefined producing 'undefined'; hand-editing the field with a typo; copying from a chat client that auto-corrected quotes.

Related errors


AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12). Data as JSON: /api/errors/2056568d40d2d733. Report an issue: GitHub.