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

PromptTemplate.init parses `nodeData.inputs?.promptValues` as JSON when it is a string. Malformed JSON triggers JSON.parse throwing inside the try, rethrown with this message.

Source

Thrown at packages/components/nodes/prompts/PromptTemplate/PromptTemplate.ts:53

                name: 'promptValues',
                type: 'json',
                optional: true,
                acceptVariable: true,
                list: true
            }
        ]
    }

    async init(nodeData: INodeData): Promise<any> {
        let template = nodeData.inputs?.template as string
        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

  1. Use valid JSON: `{"key": "value"}`.
  2. Pass an object from a prior node.
  3. Run the JSON through a linter.
  4. Improve the error message to expose parse offset and input snippet.

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(`PromptTemplate promptValues invalid JSON: ${(e as Error).message}. Got: ${promptValuesStr.slice(0,120)}`) }
} else promptValues = promptValuesStr
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(`PromptTemplate 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

When it happens

Trigger: promptValues field holds invalid JSON; non-JSON templated values pasted by the user.

Common situations: Manual editing of the promptValues field; passing a templated expression result that wasn't JSON-encoded.

Understand the failure class

Related errors


AI-assisted analysis of FlowiseAI/Flowise@abe4a8601a (2026-08-12). Data as JSON: /api/errors/96721f1f56553c9c. Report an issue: GitHub.