{"record":{"id":"135191b184ca0218","repo":"FlowiseAI/Flowise","slug":"invalid-json-in-the-chat-nvidia-nim-s-baseoptions","errorCode":null,"errorMessage":"Invalid JSON in the Chat NVIDIA NIM's baseOptions: ${exception}","messagePattern":"Invalid JSON in the Chat NVIDIA NIM's baseOptions: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/chatmodels/ChatNvdiaNIM/ChatNvdiaNIM.ts","lineNumber":158,"sourceCode":"            openAIApiKey: nvidiaNIMApiKey ?? 'sk-',\n            apiKey: nvidiaNIMApiKey ?? 'sk-',\n            streaming: streaming ?? true\n        }\n\n        if (maxTokens) obj.maxTokens = parseInt(maxTokens, 10)\n        if (topP) obj.topP = parseFloat(topP)\n        if (frequencyPenalty) obj.frequencyPenalty = parseFloat(frequencyPenalty)\n        if (presencePenalty) obj.presencePenalty = parseFloat(presencePenalty)\n        if (timeout) obj.timeout = parseInt(timeout, 10)\n        if (cache) obj.cache = cache\n\n        let parsedBaseOptions: any | undefined = undefined\n\n        if (baseOptions) {\n            try {\n                parsedBaseOptions = typeof baseOptions === 'object' ? baseOptions : JSON.parse(baseOptions)\n            } catch (exception) {\n                throw new Error(\"Invalid JSON in the Chat NVIDIA NIM's baseOptions: \" + exception)\n            }\n        }\n\n        if (basePath) await checkDenyList(basePath)\n\n        if (basePath || parsedBaseOptions) {\n            obj.configuration = {\n                baseURL: basePath,\n                defaultHeaders: parsedBaseOptions\n            }\n        }\n\n        const model = new ChatOpenAI(obj)\n        return model\n    }\n}\n\nmodule.exports = { nodeClass: ChatNvdiaNIM_ChatModels }","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/chatmodels/ChatNvdiaNIM/ChatNvdiaNIM.ts#L140-L176","documentation":"ChatNvdiaNIM parses the user-supplied baseOptions string (from the node's BaseOptions input). If baseOptions is a string and JSON.parse fails, the SyntaxError is caught and re-thrown with this label. If baseOptions is already an object it is passed through untouched.","triggerScenarios":"The BaseOptions text field in the ChatNvdiaNIM node contains malformed JSON — trailing commas, single quotes, unquoted keys, smart quotes pasted from docs, or stray comments. Only reached when baseOptions is truthy and not already an object.","commonSituations":"User pastes a curl/headers snippet that uses single quotes; copies JSON from a blog with typographic quotes; leaves a trailing comma; types a bare key like {Authorization: Bearer x}; mixes YAML-style config into the JSON field.","solutions":["Paste baseOptions through a JSON linter (jsonlint.com or `node -e 'JSON.parse(...)'`) before saving.","Use double quotes for all keys and string values, remove trailing commas, and remove comments.","If you only need headers, prefer the dedicated headers field if the node exposes one rather than baseOptions.","Pass a JS object literal instead of a string when instantiating programmatically (the typeof === 'object' branch skips parsing)."],"exampleFix":"// before (string in BaseOptions field)\n{ 'Authorization': 'Bearer xxx', } // single quotes + trailing comma -> throws [91]\n\n// after\n{ \"Authorization\": \"Bearer xxx\" }","handlingStrategy":"validation","validationCode":"function parseBaseOptions(raw) {\n  if (!raw) return undefined\n  if (typeof raw === 'object') return raw\n  try { return JSON.parse(raw) }\n  catch (e) { throw new Error(`baseOptions is not valid JSON: ${e.message}. Paste it through jsonlint.com.`) }\n}\nconst parsedBaseOptions = parseBaseOptions(nodeData.inputs?.baseOptions)","typeGuard":"function isJsonObject(v: unknown): v is Record<string, unknown> {\n  return typeof v === 'object' && v !== null && !Array.isArray(v)\n}","tryCatchPattern":"try {\n  return await initChatNvdiaNIM(nodeData, options)\n} catch (e) {\n  if (e.message.includes(\"Invalid JSON in the Chat NVIDIA NIM's baseOptions\")) {\n    throw new Error('Fix BaseOptions JSON on the ChatNvdiaNIM node; see server log for the parse error.')\n  }\n  throw e\n}","preventionTips":["Validate BaseOptions with a JSON linter before saving the node.","Prefer object inputs over string inputs when constructing programmatically.","Use a minimal {\"key\":\"value\"} and extend incrementally.","Add a UI-side JSON validator on the BaseOptions text field."],"tags":["json","configuration","validation","nvidia-nim","parsing"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}