{"record":{"id":"8572842c46c0a70b","repo":"FlowiseAI/Flowise","slug":"invalid-json-in-the-custom-document-loader-input-v","errorCode":null,"errorMessage":"Invalid JSON in the Custom Document Loader Input Variables: ${exception}","messagePattern":"Invalid JSON in the Custom Document Loader Input Variables: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/documentloaders/CustomDocumentLoader/CustomDocumentLoader.ts","lineNumber":88,"sourceCode":"        const functionInputVariablesRaw = nodeData.inputs?.functionInputVariables\n        const appDataSource = options.appDataSource as DataSource\n        const databaseEntities = options.databaseEntities as IDatabaseEntity\n\n        const variables = await getVars(appDataSource, databaseEntities, nodeData, options)\n        const flow = {\n            chatflowId: options.chatflowid,\n            sessionId: options.sessionId,\n            chatId: options.chatId,\n            input\n        }\n\n        let inputVars: ICommonObject = {}\n        if (functionInputVariablesRaw) {\n            try {\n                inputVars =\n                    typeof functionInputVariablesRaw === 'object' ? functionInputVariablesRaw : JSON.parse(functionInputVariablesRaw)\n            } catch (exception) {\n                throw new Error('Invalid JSON in the Custom Document Loader Input Variables: ' + exception)\n            }\n        }\n\n        // Some values might be a stringified JSON, parse it\n        for (const key in inputVars) {\n            let value = inputVars[key]\n            if (typeof value === 'string') {\n                value = handleEscapeCharacters(value, true)\n                if (value.startsWith('{') && value.endsWith('}')) {\n                    try {\n                        value = JSON.parse(value)\n                    } catch (e) {\n                        // ignore\n                    }\n                }\n                inputVars[key] = value\n            }\n        }","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/documentloaders/CustomDocumentLoader/CustomDocumentLoader.ts#L70-L106","documentation":"CustomDocumentLoader tries to JSON.parse the functionInputVariables input when it is a string. If the string is not valid JSON, the SyntaxError is caught and re-thrown with this prefix. When the input is already an object it is used as-is and never hits the parser.","triggerScenarios":"User typed input variables as a JS-like object literal with unquoted keys (e.g., {foo: 1}); trailing comma; single quotes instead of double quotes; copy-paste introduced smart quotes; templated variable produced a partial JSON fragment.","commonSituations":"Confusing JSON syntax with JS object literal syntax; passing a comma-separated 'key=value' list instead of JSON; a templated {{variable}} injecting unescaped quotes.","solutions":["Validate the string with JSON.parse in a scratch console before pasting it into the node.","Use double quotes around all keys and string values; remove trailing commas.","If the value is built from variables, build the object upstream and pass it as an object rather than a JSON string so the parse branch is skipped."],"exampleFix":"// before\ninputVars = typeof functionInputVariablesRaw === 'object'\n  ? functionInputVariablesRaw\n  : JSON.parse(functionInputVariablesRaw)\n// after - explicit, helpful error\nif (typeof functionInputVariablesRaw === 'object') {\n  inputVars = functionInputVariablesRaw\n} else {\n  try { inputVars = JSON.parse(functionInputVariablesRaw) }\n  catch (exception) {\n    throw new Error(`Invalid JSON in Custom Document Loader Input Variables: ${exception.message}. Input was: ${functionInputVariablesRaw}`)\n  }\n}","handlingStrategy":"validation","validationCode":"function parseInputVars(raw: unknown): Record<string, unknown> {\n  if (raw == null) return {}\n  if (typeof raw === 'object') return raw as Record<string, unknown>\n  if (typeof raw === 'string') {\n    try { return JSON.parse(raw) }\n    catch (e) { throw new Error(`functionInputVariables is not valid JSON: ${(e as Error).message}. Got: ${raw}`) }\n  }\n  throw new Error(`functionInputVariables must be an object or JSON string, got ${typeof raw}`)\n}\n// const inputVars = parseInputVars(nodeData.inputs?.functionInputVariables)","typeGuard":"function isJsonString(v: unknown): v is string {\n  if (typeof v !== 'string') return false\n  try { JSON.parse(v); return true } catch { return false }\n}","tryCatchPattern":null,"preventionTips":["Validate the JSON in a scratch console before pasting.","Use double quotes for keys and string values; drop trailing commas.","Pass the value as an object (not a JSON string) where possible to skip the parse branch."],"tags":["json","validation","configuration","custom-document-loader"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}