{"record":{"id":"67e0e8b39a8e7abd","repo":"FlowiseAI/Flowise","slug":"invalid-json-in-the-condition-agent-s-prompt-input","errorCode":null,"errorMessage":"Invalid JSON in the Condition Agent's Prompt Input Values: ${exception}","messagePattern":"Invalid JSON in the Condition Agent's Prompt Input Values: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/sequentialagents/ConditionAgent/ConditionAgent.ts","lineNumber":416,"sourceCode":"        agentPrompt = transformBracesWithColon(agentPrompt)\n        let humanPrompt = nodeData.inputs?.humanMessagePrompt as string\n        humanPrompt = transformBracesWithColon(humanPrompt)\n        const promptValuesStr = nodeData.inputs?.promptValues\n        const conditionAgentStructuredOutput = nodeData.inputs?.conditionAgentStructuredOutput\n        const model = nodeData.inputs?.model as BaseChatModel\n\n        if (!sequentialNodes || !sequentialNodes.length) throw new Error('Condition Agent must have a predecessor!')\n\n        const startLLM = sequentialNodes[0].startLLM\n        const llm = model || startLLM\n        if (nodeData.inputs) nodeData.inputs.model = llm\n\n        let conditionAgentInputVariablesValues: ICommonObject = {}\n        if (promptValuesStr) {\n            try {\n                conditionAgentInputVariablesValues = typeof promptValuesStr === 'object' ? promptValuesStr : JSON.parse(promptValuesStr)\n            } catch (exception) {\n                throw new Error(\"Invalid JSON in the Condition Agent's Prompt Input Values: \" + exception)\n            }\n        }\n        conditionAgentInputVariablesValues = handleEscapeCharacters(conditionAgentInputVariablesValues, true)\n\n        const conditionAgentInputVariables = uniq([...getInputVariables(agentPrompt), ...getInputVariables(humanPrompt)])\n\n        if (!conditionAgentInputVariables.every((element) => Object.keys(conditionAgentInputVariablesValues).includes(element))) {\n            throw new Error('Condition Agent input variables values are not provided!')\n        }\n\n        const abortControllerSignal = options.signal as AbortController\n\n        const conditionalEdge = async (state: ISeqAgentsState, config: RunnableConfig) =>\n            await runCondition(\n                conditionName,\n                nodeData,\n                input,\n                options,","sourceCodeStart":398,"sourceCodeEnd":434,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/sequentialagents/ConditionAgent/ConditionAgent.ts#L398-L434","documentation":"Same JSON-parse guard as error 281 but on the ConditionAgent node. When `promptValuesStr` is a non-empty string and `JSON.parse` throws, the exception is wrapped with the Condition Agent-specific prefix.","triggerScenarios":"Calling ConditionAgent.init with `nodeData.inputs.promptValues` set to a string that is not valid JSON.","commonSituations":"User typed free-form text in the Condition Agent's Prompt Input Values; pasted content with smart quotes; single-quoted keys; trailing commas.","solutions":["Provide a valid JSON object string, e.g. `{\"topic\":\"sports\"}`.","Pass the value as an already-parsed object so the `typeof === 'object'` branch skips JSON.parse.","Verify with `JSON.parse(value)` in a console before saving."],"exampleFix":"// before\nnodeData.inputs.promptValues = \"topic: sports\" // throws [296]\n\n// after\nnodeData.inputs.promptValues = '{\"topic\":\"sports\"}'","handlingStrategy":"validation","validationCode":"function parsePromptValuesSafe(raw) {\n  if (raw == null) return {}\n  if (typeof raw === 'object') return raw\n  try {\n    const parsed = JSON.parse(raw)\n    if (typeof parsed !== 'object' || Array.isArray(parsed) || parsed === null) {\n      throw new Error('Condition Agent promptValues must be a JSON object.')\n    }\n    return parsed\n  } catch (e) {\n    throw new Error(`Condition Agent promptValues is not valid JSON: ${e.message}`)\n  }\n}\n\nparsePromptValuesSafe(nodeData.inputs.promptValues)","typeGuard":"function isJsonObjectString(s): s is string {\n  if (typeof s !== 'string') return false\n  try { const v = JSON.parse(s); return typeof v === 'object' && v !== null && !Array.isArray(v) }\n  catch { return false }\n}","tryCatchPattern":null,"preventionTips":["Always use double-quoted keys in JSON.","Lint the JSON before saving.","Pass a parsed object directly when calling init from code."],"tags":["configuration","json","input-validation","prompts"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}