FlowiseAI/Flowise · error · Error
Invalid JSON in the PromptTemplate's promptValues: ${excepti
Error message
Invalid JSON in the PromptTemplate's promptValues: ${exception} What it means
PromptLangfuse.init fetches a prompt from Langfuse then parses `nodeData.inputs?.promptValues` as JSON. If the values string is malformed, JSON.parse throws and is rethrown with this message. Note the message labels it 'PromptTemplate' which is slightly misleading for the Langfuse variant.
Source
Thrown at packages/components/nodes/prompts/PromptLangfuse/PromptLangfuse.ts:76
const langfuse = new Langfuse({
secretKey: langFuseSecretKey,
publicKey: langFusePublicKey,
baseUrl: langFuseEndpoint ?? 'https://cloud.langfuse.com',
sdkIntegration: 'Flowise'
})
const langfusePrompt = await langfuse.getPrompt(nodeData.inputs?.template as string)
let template = langfusePrompt.getLangchainPrompt()
const promptValuesStr = nodeData.inputs?.promptValues
let promptValues: ICommonObject = {}
if (promptValuesStr) {
try {
promptValues = typeof promptValuesStr === 'object' ? promptValuesStr : JSON.parse(promptValuesStr)
} catch (exception) {
throw new Error("Invalid JSON in the PromptTemplate's promptValues: " + exception)
}
}
const inputVariables = getInputVariables(template)
template = transformBracesWithColon(template)
try {
const options: PromptTemplateInput = {
template,
inputVariables
}
const prompt = new PromptTemplate(options)
prompt.promptValues = promptValues
return prompt
} catch (e) {
throw new Error(e)
}
}View on GitHub (pinned to abe4a8601a)
Solutions
- Provide promptValues as valid JSON with double-quoted keys.
- Pass an object from an upstream node to bypass JSON.parse.
- Cross-check placeholder names against the Langfuse prompt via `getInputVariables(template)`.
- Fix the misleading message text to say 'PromptLangfuse'.
Example fix
// before
throw new Error("Invalid JSON in the PromptTemplate's promptValues: " + exception)
// after
throw new Error(`Invalid JSON in PromptLangfuse promptValues: ${exception instanceof Error ? exception.message : exception}. Input: ${promptValuesStr.slice(0,120)}`) Defensive patterns
Strategy: validation
Validate before calling
function parsePromptValues(input: unknown): ICommonObject {
if (input == null) return {}
if (typeof input === 'object') return input as ICommonObject
try { return JSON.parse(input) }
catch (e) { throw new Error(`PromptLangfuse promptValues invalid JSON: ${(e as Error).message}`) }
} Type guard
const isPlainObject = (v: unknown): v is Record<string, unknown> => typeof v === 'object' && v !== null && !Array.isArray(v)
Prevention
- Use valid JSON for promptValues.
- Cross-check placeholder names against the Langfuse prompt.
- Pass objects when possible.
When it happens
Trigger: User supplies promptValues as a non-JSON string alongside a Langfuse-managed prompt; Langfuse returns a template with placeholders the user tries to fill via a malformed JSON blob.
Common situations: Mixing Langfuse-hosted prompts with locally typed prompt values; pasting values from a different prompt system that uses non-JSON syntax.
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 ChatPromptTemplate's promptValues: ${exc
- Invalid JSON in the FewShotPromptTemplate's examples: ${exce
- Invalid JSON in the PromptTemplate's promptValues: ${excepti
AI-assisted analysis of FlowiseAI/Flowise@abe4a8601a (2026-08-12).
Data as JSON: /api/errors/37fda34b75ba63d6.
Report an issue: GitHub.