{"record":{"id":"2056568d40d2d733","repo":"n8n-io/n8n","slug":"additional-model-request-fields-must-be-valid-json","errorCode":null,"errorMessage":"Additional Model Request Fields must be valid JSON","messagePattern":"Additional Model Request Fields must be valid JSON","errorType":"validation","errorClass":"UserError","httpStatus":null,"severity":"warning","filePath":"packages/@n8n/nodes-langchain/nodes/embeddings/EmbeddingsAwsBedrock/EmbeddingsAwsBedrock.node.ts","lineNumber":156,"sourceCode":"\n\t\tconst region = resolveBedrockRegion(modelName, credentialRegion);\n\n\t\tconst client = createBedrockRuntimeClient({\n\t\t\tregion,\n\t\t\tcredentials,\n\t\t\tbedrockRuntimeEndpoint,\n\t\t\tmaxRetries: options.maxRetries,\n\t\t\ttimeout: options.timeout,\n\t\t});\n\n\t\tlet additionalModelRequestFields: Record<string, unknown> | undefined;\n\t\tconst additionalFields = options.additionalModelRequestFields?.trim();\n\t\tif (additionalFields && additionalFields !== '{}') {\n\t\t\tlet parsed: unknown;\n\t\t\ttry {\n\t\t\t\tparsed = jsonParse(additionalFields);\n\t\t\t} catch {\n\t\t\t\tthrow new UserError('Additional Model Request Fields must be valid JSON', {\n\t\t\t\t\tlevel: 'warning',\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (!isJsonObject(parsed)) {\n\t\t\t\tthrow new UserError('Additional Model Request Fields must be a JSON object', {\n\t\t\t\t\tlevel: 'warning',\n\t\t\t\t});\n\t\t\t}\n\t\t\tadditionalModelRequestFields = parsed;\n\t\t}\n\n\t\tconst embeddings = new BedrockInvokeModelEmbeddings({\n\t\t\tclient,\n\t\t\tmodel: modelName,\n\t\t\tadditionalModelRequestFields,\n\t\t});\n\n\t\treturn {","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/nodes-langchain/nodes/embeddings/EmbeddingsAwsBedrock/EmbeddingsAwsBedrock.node.ts#L138-L174","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Open the 'Additional Model Request Fields' option and paste minimal valid JSON, e.g. {\"dimensions\": 256}.","Validate the string in a JSON linter (jsonlint.com) before saving.","If the value is templated, wrap it so it always emits valid JSON or leave the field empty when no overrides are needed.","Use {} or leave blank — the code skips parsing entirely when the trimmed value is empty or '{}'."],"exampleFix":"// before\noptions.additionalModelRequestFields = \"dimensions: 256\"\n// after\noptions.additionalModelRequestFields = \"{\\\"dimensions\\\": 256}\"","handlingStrategy":"validation","validationCode":"const raw = options.additionalModelRequestFields?.trim();\nif (raw && raw !== '{}') {\n  let parsed;\n  try { parsed = JSON.parse(raw); }\n  catch (e) {\n    // show inline UI validation; do not let execution reach supplyData\n    throw new Error(`Fix JSON in 'Additional Model Request Fields': ${(e as Error).message}`);\n  }\n}","typeGuard":"const isJsonString = (s: string): boolean => {\n  try { JSON.parse(s); return true; } catch { return false; }\n};","tryCatchPattern":"// Pre-validate at UI/save time; runtime catch only rewraps into the UserError.","preventionTips":["Validate JSON option fields with a linter as the user types in the n8n UI.","Run workflow JSON through a validator that JSON.parses every additionalModelRequestFields-like option before activation.","Prefer empty '{}' over partial strings; consult Bedrock docs for allowed keys."],"tags":["bedrock","embeddings","json","configuration","user-input"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}