FlowiseAI/Flowise · error · Error
Invalid JSON in the OpenAI's BaseOptions:
Error message
Invalid JSON in the OpenAI's BaseOptions:
What it means
OpenAI LLM node's baseOptions branch: JSON.parse runs only when baseOptions is not an object; a SyntaxError is caught and re-thrown with this prefix. Object inputs skip parsing.
Source
Thrown at packages/components/nodes/llms/OpenAI/OpenAI.ts:184
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 (batchSize) obj.batchSize = parseInt(batchSize, 10)
if (bestOf) obj.bestOf = parseInt(bestOf, 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 OpenAI's BaseOptions: " + exception)
}
}
if (basePath || parsedBaseOptions) {
obj.configuration = {
baseURL: basePath,
defaultHeaders: parsedBaseOptions
}
}
const model = new OpenAI(obj)
return model
}
}
module.exports = { nodeClass: OpenAI_LLMs }
View on GitHub (pinned to abe4a8601a)
Solutions
- Validate baseOptions as JSON in the UI before saving.
- Pass baseOptions as an object to bypass the parse branch.
- Lint the JSON (jq . <<< "$opts") to find the exact syntax error.
Example fix
// before
{ temperature: 0.7, top_p: 0.9, }
// after
{"temperature":0.7,"top_p":0.9} Defensive patterns
Strategy: validation
Validate before calling
function parseBaseOptions(raw: unknown): Record<string, unknown> | undefined {
if (raw == null) return undefined
if (typeof raw === 'object') return raw as Record<string, unknown>
if (typeof raw === 'string') JSON.parse(raw)
return undefined
} Type guard
function isJsonObjectString(v: string): v is string {
try { const o = JSON.parse(v); return typeof o === 'object' && o !== null } catch { return false }
} Try / catch
try {
parsedBaseOptions = typeof baseOptions === 'object' ? baseOptions : JSON.parse(baseOptions)
} catch (e) {
throw new Error(`BaseOptions is not valid JSON: ${(e as Error).message}`)
} Prevention
- Quote all keys and string values in BaseOptions.
- Pass an object when possible to skip parsing.
- Lint JSON in CI.
- Avoid trailing commas.
When it happens
Trigger: Free-form BaseOptions string in the OpenAI LLM node that is not valid JSON (trailing comma, single quotes, unquoted keys, stray characters).
Common situations: Pasting a JS object literal into the field; curly-quote corruption; stale config migrated from an object to a string representation.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Invalid JSON in the OpenAIEmbedding's BaseOptions:
- Invalid JSON in the ChatOpenAI's BaseOptions:
- Invalid JSON in the Chat NVIDIA NIM's baseOptions: ${excepti
- Invalid JSON in the ChatOpenAI's BaseOptions: ${exception}
- Invalid JSON in the Additional Configuration:
AI-assisted analysis of FlowiseAI/Flowise@abe4a8601a (2026-08-12).
Data as JSON: /api/errors/8373ff192438e671.
Report an issue: GitHub.