{"record":{"id":"43d5b18942089307","repo":"FlowiseAI/Flowise","slug":"invalid-json-in-the-chatprompttemplate-s-promptval","errorCode":null,"errorMessage":"Invalid JSON in the ChatPromptTemplate's promptValues: ${exception}","messagePattern":"Invalid JSON in the ChatPromptTemplate's promptValues: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/prompts/ChatPromptTemplate/ChatPromptTemplate.ts","lineNumber":156,"sourceCode":"                if (!Array.isArray(parsedResponse)) {\n                    throw new Error('Returned message history must be an array')\n                }\n                prompt = ChatPromptTemplate.fromMessages([\n                    SystemMessagePromptTemplate.fromTemplate(systemMessagePrompt),\n                    ...parsedResponse,\n                    HumanMessagePromptTemplate.fromTemplate(humanMessagePrompt)\n                ])\n            } catch (e) {\n                throw new Error(e)\n            }\n        }\n\n        let promptValues: ICommonObject = {}\n        if (promptValuesStr) {\n            try {\n                promptValues = typeof promptValuesStr === 'object' ? promptValuesStr : JSON.parse(promptValuesStr)\n            } catch (exception) {\n                throw new Error(\"Invalid JSON in the ChatPromptTemplate's promptValues: \" + exception)\n            }\n        }\n        // @ts-ignore\n        prompt.promptValues = promptValues\n\n        return prompt\n    }\n}\n\nmodule.exports = { nodeClass: ChatPromptTemplate_Prompts }\n","sourceCodeStart":138,"sourceCodeEnd":167,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/prompts/ChatPromptTemplate/ChatPromptTemplate.ts#L138-L167","documentation":"ChatPromptTemplate.init parses `nodeData.inputs?.promptValues` as JSON when it is a string. If the user typed invalid JSON, JSON.parse throws and the catch rethrows with this message.","triggerScenarios":"promptValues field contains malformed JSON — single quotes, trailing commas, unquoted keys, JS object literal syntax.","commonSituations":"Manually typing prompt values in the node UI; passing values from an expression that did not JSON-encode; copy-paste from a JS source file.","solutions":["Use valid JSON with double-quoted keys and string values.","Pass an actual object (from a previous node) to skip the parse path.","Validate the JSON in an external linter first.","Improve the error to include the parse offset and a snippet of the input."],"exampleFix":"// before\npromptValues = typeof promptValuesStr === 'object' ? promptValuesStr : JSON.parse(promptValuesStr)\n// after\nif (typeof promptValuesStr === 'string') {\n  try { promptValues = JSON.parse(promptValuesStr) }\n  catch (e) { throw new Error(`promptValues JSON parse failed: ${(e as Error).message}. Input: ${promptValuesStr.slice(0,120)}`) }\n} else promptValues = promptValuesStr","handlingStrategy":"validation","validationCode":"function parseJsonOrThrow(s: string, label: string): ICommonObject {\n  try { return JSON.parse(s) }\n  catch (e) { throw new Error(`${label} invalid JSON: ${(e as Error).message}`) }\n}","typeGuard":"const isJson = (s: string): boolean => { try { JSON.parse(s); return true } catch { return false } }","tryCatchPattern":null,"preventionTips":["Use double-quoted JSON keys and string values.","Pass objects between nodes to skip parsing.","Lint before pasting."],"tags":["json","validation","prompt","chat-template"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}