FlowiseAI/Flowise · error · Error

Invalid JSON in the Chat NVIDIA NIM's baseOptions: ${excepti

Error message

Invalid JSON in the Chat NVIDIA NIM's baseOptions: ${exception}

What it means

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.

Source

Thrown at packages/components/nodes/chatmodels/ChatNvdiaNIM/ChatNvdiaNIM.ts:158

            openAIApiKey: nvidiaNIMApiKey ?? 'sk-',
            apiKey: nvidiaNIMApiKey ?? 'sk-',
            streaming: streaming ?? true
        }

        if (maxTokens) obj.maxTokens = parseInt(maxTokens, 10)
        if (topP) obj.topP = parseFloat(topP)
        if (frequencyPenalty) obj.frequencyPenalty = parseFloat(frequencyPenalty)
        if (presencePenalty) obj.presencePenalty = parseFloat(presencePenalty)
        if (timeout) obj.timeout = parseInt(timeout, 10)
        if (cache) obj.cache = cache

        let parsedBaseOptions: any | undefined = undefined

        if (baseOptions) {
            try {
                parsedBaseOptions = typeof baseOptions === 'object' ? baseOptions : JSON.parse(baseOptions)
            } catch (exception) {
                throw new Error("Invalid JSON in the Chat NVIDIA NIM's baseOptions: " + exception)
            }
        }

        if (basePath) await checkDenyList(basePath)

        if (basePath || parsedBaseOptions) {
            obj.configuration = {
                baseURL: basePath,
                defaultHeaders: parsedBaseOptions
            }
        }

        const model = new ChatOpenAI(obj)
        return model
    }
}

module.exports = { nodeClass: ChatNvdiaNIM_ChatModels }

View on GitHub (pinned to abe4a8601a)

Solutions

  1. Paste baseOptions through a JSON linter (jsonlint.com or `node -e 'JSON.parse(...)'`) before saving.
  2. Use double quotes for all keys and string values, remove trailing commas, and remove comments.
  3. If you only need headers, prefer the dedicated headers field if the node exposes one rather than baseOptions.
  4. Pass a JS object literal instead of a string when instantiating programmatically (the typeof === 'object' branch skips parsing).

Example fix

// before (string in BaseOptions field)
{ 'Authorization': 'Bearer xxx', } // single quotes + trailing comma -> throws [91]

// after
{ "Authorization": "Bearer xxx" }
Defensive patterns

Strategy: validation

Validate before calling

function parseBaseOptions(raw) {
  if (!raw) return undefined
  if (typeof raw === 'object') return raw
  try { return JSON.parse(raw) }
  catch (e) { throw new Error(`baseOptions is not valid JSON: ${e.message}. Paste it through jsonlint.com.`) }
}
const parsedBaseOptions = parseBaseOptions(nodeData.inputs?.baseOptions)

Type guard

function isJsonObject(v: unknown): v is Record<string, unknown> {
  return typeof v === 'object' && v !== null && !Array.isArray(v)
}

Try / catch

try {
  return await initChatNvdiaNIM(nodeData, options)
} catch (e) {
  if (e.message.includes("Invalid JSON in the Chat NVIDIA NIM's baseOptions")) {
    throw new Error('Fix BaseOptions JSON on the ChatNvdiaNIM node; see server log for the parse error.')
  }
  throw e
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Related errors


AI-assisted analysis of FlowiseAI/Flowise@abe4a8601a (2026-08-12). Data as JSON: /api/errors/135191b184ca0218. Report an issue: GitHub.