FlowiseAI/Flowise · error · Error
Invalid JSON in the ChatPromptTemplate's promptValues: ${exc
Error message
Invalid JSON in the ChatPromptTemplate's promptValues: ${exception} What it means
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.
Source
Thrown at packages/components/nodes/prompts/ChatPromptTemplate/ChatPromptTemplate.ts:156
if (!Array.isArray(parsedResponse)) {
throw new Error('Returned message history must be an array')
}
prompt = ChatPromptTemplate.fromMessages([
SystemMessagePromptTemplate.fromTemplate(systemMessagePrompt),
...parsedResponse,
HumanMessagePromptTemplate.fromTemplate(humanMessagePrompt)
])
} catch (e) {
throw new Error(e)
}
}
let promptValues: ICommonObject = {}
if (promptValuesStr) {
try {
promptValues = typeof promptValuesStr === 'object' ? promptValuesStr : JSON.parse(promptValuesStr)
} catch (exception) {
throw new Error("Invalid JSON in the ChatPromptTemplate's promptValues: " + exception)
}
}
// @ts-ignore
prompt.promptValues = promptValues
return prompt
}
}
module.exports = { nodeClass: ChatPromptTemplate_Prompts }
View on GitHub (pinned to abe4a8601a)
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.
Example fix
// before
promptValues = typeof promptValuesStr === 'object' ? promptValuesStr : JSON.parse(promptValuesStr)
// after
if (typeof promptValuesStr === 'string') {
try { promptValues = JSON.parse(promptValuesStr) }
catch (e) { throw new Error(`promptValues JSON parse failed: ${(e as Error).message}. Input: ${promptValuesStr.slice(0,120)}`) }
} else promptValues = promptValuesStr Defensive patterns
Strategy: validation
Validate before calling
function parseJsonOrThrow(s: string, label: string): ICommonObject {
try { return JSON.parse(s) }
catch (e) { throw new Error(`${label} invalid JSON: ${(e as Error).message}`) }
} Type guard
const isJson = (s: string): boolean => { try { JSON.parse(s); return true } catch { return false } } Prevention
- Use double-quoted JSON keys and string values.
- Pass objects between nodes to skip parsing.
- Lint before pasting.
When it happens
Trigger: promptValues field contains malformed JSON — single quotes, trailing commas, unquoted keys, JS object literal syntax.
Common situations: 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.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Invalid JSON in the Worker's Prompt Input Values: ${exceptio
- Returned message history must be an array
- Invalid JSON in the FewShotPromptTemplate's examples: ${exce
- Invalid JSON in the PromptTemplate's promptValues: ${excepti
- Invalid JSON in the PromptTemplate's promptValues: ${excepti
AI-assisted analysis of FlowiseAI/Flowise@abe4a8601a (2026-08-12).
Data as JSON: /api/errors/43d5b18942089307.
Report an issue: GitHub.