{"record":{"id":"0a8c4ea2d1c3fa70","repo":"n8n-io/n8n","slug":"additional-model-request-fields-must-be-a-json-obj","errorCode":null,"errorMessage":"Additional Model Request Fields must be a JSON object","messagePattern":"Additional Model Request Fields must be a JSON object","errorType":"validation","errorClass":"UserError","httpStatus":null,"severity":"warning","filePath":"packages/@n8n/nodes-langchain/nodes/embeddings/EmbeddingsAwsBedrock/EmbeddingsAwsBedrock.node.ts","lineNumber":161,"sourceCode":"\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 {\n\t\t\tresponse: logWrapper(embeddings, this),\n\t\t};\n\t}\n}\n","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/nodes-langchain/nodes/embeddings/EmbeddingsAwsBedrock/EmbeddingsAwsBedrock.node.ts#L143-L179","documentation":"Companion to error 682: thrown after jsonParse succeeds but isJsonObject(parsed) is false. The Bedrock InvokeModel API requires additionalModelRequestFields to be a JSON object (key/value pairs); a JSON array, number, string, or boolean is syntactically valid JSON but semantically wrong, so the UserError pinpoints the shape problem.","triggerScenarios":"User enters [1,2,3], 256, true, or \"hello\" in 'Additional Model Request Fields' — parses cleanly as JSON but is not an object. Also triggered by a templated expression returning a JSON array literal.","commonSituations":"Confusing the field with a list-style option; pasting an array of model IDs instead of request overrides; templating that emits a primitive.","solutions":["Wrap the value in an object: pass {\"key\": \"value\"} rather than a bare array or primitive.","If you only intended one override, find the correct parameter name in the Bedrock model docs and use it as a key.","Leave the field empty (or {}) when no additional fields are required."],"exampleFix":"// before\noptions.additionalModelRequestFields = \"[512, 1024]\"\n// after\noptions.additionalModelRequestFields = \"{\\\"dimensions\\\": 512}\"","handlingStrategy":"type-guard","validationCode":"const parsed = JSON.parse(raw);\nif (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {\n  throw new Error('Additional Model Request Fields must be a JSON object');\n}","typeGuard":"const isJsonObject = (v: unknown): v is Record<string, unknown> =>\n  typeof v === 'object' && v !== null && !Array.isArray(v);","tryCatchPattern":"// Validate shape after parsing; reject non-objects before they reach the node.","preventionTips":["Always wrap overrides in an object literal: {\"key\": value}.","Document with examples in the node's option description.","Add a CI check that scans for additionalModelRequestFields values that are arrays/primitives."],"tags":["bedrock","embeddings","json","type-mismatch","configuration"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}