{"record":{"id":"0a45799b400080cd","repo":"FlowiseAI/Flowise","slug":"invalid-json-in-the-chatopenai-s-baseoptions","errorCode":null,"errorMessage":"Invalid JSON in the ChatOpenAI's BaseOptions: ","messagePattern":"Invalid JSON in the ChatOpenAI's BaseOptions: ","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/embeddings/OpenAIEmbeddingCustom/OpenAIEmbeddingCustom.ts","lineNumber":132,"sourceCode":"        const openAIApiKey = getCredentialParam('openAIApiKey', credentialData, nodeData)\n\n        const obj: Partial<OpenAIEmbeddingsParams> & { openAIApiKey?: string; configuration?: ClientOptions } = {\n            openAIApiKey\n        }\n\n        if (stripNewLines) obj.stripNewLines = stripNewLines\n        if (batchSize) obj.batchSize = parseInt(batchSize, 10)\n        if (timeout) obj.timeout = parseInt(timeout, 10)\n        if (modelName) obj.modelName = modelName\n        if (dimensions) obj.dimensions = parseInt(dimensions, 10)\n        if (encodingFormat) obj.encodingFormat = encodingFormat\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 ChatOpenAI'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 OpenAIEmbeddings(obj)\n        return model\n    }\n}\n\nmodule.exports = { nodeClass: OpenAIEmbeddingCustom_Embeddings }\n","sourceCodeStart":114,"sourceCodeEnd":149,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/embeddings/OpenAIEmbeddingCustom/OpenAIEmbeddingCustom.ts#L114-L149","documentation":"Same JSON.parse branch as OpenAIEmbedding, in the Custom variant. The message text says \"ChatOpenAI's\" but the node is an embeddings node (OpenAIEmbeddings) — the string is a copy-paste artifact and does not change behavior.","triggerScenarios":"Custom OpenAI-compatible endpoint node receives a baseOptions string that fails JSON.parse (trailing comma, single quotes, malformed JSON).","commonSituations":"Pasting a JS object literal into the BaseOptions field; quote-style mismatch; using a custom OpenAI-compatible provider with extra headers supplied as a malformed string.","solutions":["Validate the baseOptions string with JSON.parse before submitting.","Supply baseOptions as an object so the parse branch is skipped.","If debugging, ignore the misleading 'ChatOpenAI' wording and treat as an embeddings BaseOptions error."],"exampleFix":"// before\n{ baseURL: 'http://localhost:8000/v1' }\n// after\n{\"baseURL\":\"http://localhost:8000/v1\"}","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 isJsonString(v: string): v is string {\n  try { JSON.parse(v); return true } catch { return false }\n}","tryCatchPattern":"try {\n  parsedBaseOptions = typeof baseOptions === 'object' ? baseOptions : JSON.parse(baseOptions)\n} catch (e) {\n  throw new Error(`BaseOptions (embeddings) is not valid JSON: ${(e as Error).message}`)\n}","preventionTips":["Remember the message says 'ChatOpenAI' but the node is embeddings - validate the embeddings BaseOptions.","Pass an object to skip the parse branch.","Lint the JSON before saving the node.","Avoid JS object-literal syntax in the field."],"tags":["openai","embeddings","json","validation","parsing","custom-endpoint"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}