{"record":{"id":"8373ff192438e671","repo":"FlowiseAI/Flowise","slug":"invalid-json-in-the-openai-s-baseoptions","errorCode":null,"errorMessage":"Invalid JSON in the OpenAI's BaseOptions: ","messagePattern":"Invalid JSON in the OpenAI's BaseOptions: ","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/llms/OpenAI/OpenAI.ts","lineNumber":184,"sourceCode":"            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 (batchSize) obj.batchSize = parseInt(batchSize, 10)\n        if (bestOf) obj.bestOf = parseInt(bestOf, 10)\n\n        if (cache) obj.cache = cache\n\n        let parsedBaseOptions: any | undefined = undefined\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 OpenAI's BaseOptions: \" + exception)\n            }\n        }\n\n        if (basePath || parsedBaseOptions) {\n            obj.configuration = {\n                baseURL: basePath,\n                defaultHeaders: parsedBaseOptions\n            }\n        }\n\n        const model = new OpenAI(obj)\n        return model\n    }\n}\n\nmodule.exports = { nodeClass: OpenAI_LLMs }\n","sourceCodeStart":166,"sourceCodeEnd":201,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/llms/OpenAI/OpenAI.ts#L166-L201","documentation":"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.","triggerScenarios":"Free-form BaseOptions string in the OpenAI LLM node that is not valid JSON (trailing comma, single quotes, unquoted keys, stray characters).","commonSituations":"Pasting a JS object literal into the field; curly-quote corruption; stale config migrated from an object to a string representation.","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."],"exampleFix":"// before\n{ temperature: 0.7, top_p: 0.9, }\n// after\n{\"temperature\":0.7,\"top_p\":0.9}","handlingStrategy":"validation","validationCode":"function parseBaseOptions(raw: unknown): Record<string, unknown> | undefined {\n  if (raw == null) return undefined\n  if (typeof raw === 'object') return raw as Record<string, unknown>\n  if (typeof raw === 'string') JSON.parse(raw)\n  return undefined\n}","typeGuard":"function isJsonObjectString(v: string): v is string {\n  try { const o = JSON.parse(v); return typeof o === 'object' && o !== null } catch { return false }\n}","tryCatchPattern":"try {\n  parsedBaseOptions = typeof baseOptions === 'object' ? baseOptions : JSON.parse(baseOptions)\n} catch (e) {\n  throw new Error(`BaseOptions is not valid JSON: ${(e as Error).message}`)\n}","preventionTips":["Quote all keys and string values in BaseOptions.","Pass an object when possible to skip parsing.","Lint JSON in CI.","Avoid trailing commas."],"tags":["openai","llm","json","validation","parsing"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}