{"record":{"id":"27c7355a3c71127b","repo":"FlowiseAI/Flowise","slug":"invalid-json-in-the-chatsambanova-s-baseoptions","errorCode":null,"errorMessage":"Invalid JSON in the ChatSambanova's BaseOptions: ${exception}","messagePattern":"Invalid JSON in the ChatSambanova's BaseOptions: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/chatmodels/ChatSambanova/ChatSambanova.ts","lineNumber":109,"sourceCode":"        const sambanovaApiKey = getCredentialParam('sambanovaApiKey', credentialData, nodeData)\n\n        const obj: ChatOpenAIFields = {\n            temperature: temperature ? parseFloat(temperature) : undefined,\n            model: modelName,\n            apiKey: sambanovaApiKey,\n            openAIApiKey: sambanovaApiKey,\n            streaming: streaming ?? true\n        }\n\n        if (cache) obj.cache = cache\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 ChatSambanova'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 ChatOpenAI(obj)\n        return model\n    }\n}\n\nmodule.exports = { nodeClass: ChatSambanova_ChatModels }\n","sourceCodeStart":91,"sourceCodeEnd":126,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/chatmodels/ChatSambanova/ChatSambanova.ts#L91-L126","documentation":"ChatSambanova wraps ChatOpenAI and parses its own BaseOptions field identically to the OpenAI-compatible siblings. A string that fails JSON.parse is re-thrown with this label; objects pass through into defaultHeaders under configuration.","triggerScenarios":"The ChatSambanova node's BaseOptions field holds malformed JSON; the failure surface is identical to [92]/[94]. Reached only when baseOptions is a truthy string.","commonSituations":"Users adding Sambanova-specific headers (e.g. for routing or tracing) paste Python-dict-style or single-quoted JSON; trailing commas from relaxed editors; smart quotes from chat clients; mixing Authorization into BaseOptions instead of using the API key field.","solutions":["JSON-lint the BaseOptions value and correct syntax errors.","Use double-quoted keys/values; remove trailing commas and comments.","Pass an object input when constructing programmatically to bypass JSON.parse.","Start from a minimal {\"X-Header\":\"value\"} and extend incrementally."],"exampleFix":"// before\n{ 'X-Trace': 'abc', } // single quotes + trailing comma -> throws [97]\n\n// after\n{ \"X-Trace\": \"abc\" }","handlingStrategy":"validation","validationCode":"function parseBaseOptions(raw) {\n  if (!raw) return undefined\n  if (typeof raw === 'object') return raw\n  try { return JSON.parse(raw) }\n  catch (e) { throw new Error(`ChatSambanova BaseOptions JSON invalid: ${e.message}`) }\n}\nconst parsedBaseOptions = parseBaseOptions(nodeData.inputs?.baseOptions)","typeGuard":"function isHeadersObject(v: unknown): v is Record<string, string> {\n  if (typeof v !== 'object' || v === null || Array.isArray(v)) return false\n  return Object.values(v).every(x => typeof x === 'string')\n}","tryCatchPattern":"try {\n  return await initChatSambanova(nodeData, options)\n} catch (e) {\n  if (e.message.includes(\"Invalid JSON in the ChatSambanova's BaseOptions\")) {\n    throw new Error('Fix BaseOptions JSON on the ChatSambanova node.')\n  }\n  throw e\n}","preventionTips":["JSON-lint BaseOptions before saving.","Prefer object inputs when constructing programmatically.","Do not put Authorization here; use the API key field.","Add a UI-side JSON validator."],"tags":["json","configuration","validation","sambanova","default-headers"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}