{"record":{"id":"2e207c9bcc000833","repo":"FlowiseAI/Flowise","slug":"invalid-json-in-the-openaiembedding-s-baseoptions","errorCode":null,"errorMessage":"Invalid JSON in the OpenAIEmbedding's BaseOptions: ","messagePattern":"Invalid JSON in the OpenAIEmbedding's BaseOptions: ","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/embeddings/OpenAIEmbedding/OpenAIEmbedding.ts","lineNumber":145,"sourceCode":"\n        const obj: Partial<OpenAIEmbeddingsParams> & { openAIApiKey?: string; configuration?: ClientOptions } = {\n            openAIApiKey,\n            modelName\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 (dimensions) obj.dimensions = parseInt(dimensions, 10)\n        if (encodingFormat) obj.encodingFormat = encodingFormat\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 OpenAIEmbedding'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: OpenAIEmbedding_Embeddings }\n","sourceCodeStart":127,"sourceCodeEnd":162,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/embeddings/OpenAIEmbedding/OpenAIEmbedding.ts#L127-L162","documentation":"The OpenAIEmbedding node only calls JSON.parse(baseOptions) when baseOptions is a non-object value; a thrown SyntaxError is caught and re-thrown with this prefix. Object inputs bypass parsing entirely.","triggerScenarios":"User enters free-form Additional Options in the Flowise node UI that are not valid JSON: trailing commas, single quotes, unquoted keys, or a stray JS object literal pasted verbatim.","commonSituations":"Copy-paste of a JS object literal instead of JSON; mismatched/curly quotes from a word processor; empty-ish string like '{}' with trailing characters; previous config that worked as an object now passed as a string.","solutions":["Validate the baseOptions field as JSON in the node UI before saving.","Pass baseOptions as a JS object rather than a string so the parse branch is skipped.","Run the value through a JSON linter (jsonlint.com / jq) to locate the syntax error."],"exampleFix":"// before\n{ model: 'text-embedding-3-small', temperature: 0 }\n// after\n{\"model\":\"text-embedding-3-small\"}","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) // throws early with a clear SyntaxError\n  return undefined\n}\nconst parsedBaseOptions = parseBaseOptions(baseOptions)","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":["Always quote keys and string values in the BaseOptions field.","Prefer passing an object over a JSON string when the API allows it.","Lint JSON configs in CI before deploy.","Avoid pasting from word processors that convert quotes."],"tags":["openai","embeddings","json","validation","parsing"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}