{"record":{"id":"fb739dabf6cd8610","repo":"FlowiseAI/Flowise","slug":"key-is-required","errorCode":null,"errorMessage":"Key is required","messagePattern":"Key is required","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/sequentialagents/Agent/Agent.ts","lineNumber":905,"sourceCode":"    const variables = await getVars(appDataSource, databaseEntities, nodeData, options)\n\n    const flow = {\n        chatflowId: options.chatflowid,\n        sessionId: options.sessionId,\n        chatId: options.chatId,\n        input,\n        output,\n        state,\n        vars: prepareSandboxVars(variables)\n    }\n\n    if (updateStateMemory && updateStateMemory !== 'updateStateMemoryUI' && updateStateMemory !== 'updateStateMemoryCode') {\n        try {\n            const parsedSchema = typeof updateStateMemory === 'string' ? JSON.parse(updateStateMemory) : updateStateMemory\n            const obj: ICommonObject = {}\n            for (const sch of parsedSchema) {\n                const key = sch.Key\n                if (!key) throw new Error(`Key is required`)\n                let value = sch.Value as string\n                if (value.startsWith('$flow')) {\n                    value = customGet(flow, sch.Value.replace('$flow.', ''))\n                } else if (value.startsWith('$vars')) {\n                    value = customGet(flow, sch.Value.replace('$', ''))\n                }\n                obj[key] = value\n            }\n            return obj\n        } catch (e) {\n            throw new Error(e)\n        }\n    }\n\n    if (selectedTab === 'updateStateMemoryUI' && updateStateMemoryUI) {\n        try {\n            const parsedSchema = typeof updateStateMemoryUI === 'string' ? JSON.parse(updateStateMemoryUI) : updateStateMemoryUI\n            const obj: ICommonObject = {}","sourceCodeStart":887,"sourceCodeEnd":923,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/sequentialagents/Agent/Agent.ts#L887-L923","documentation":"Thrown in the JSON-schema branch of `getUpdateStateMemory` (`updateStateMemory` tab) when iterating `parsedSchema` and a row has no `Key` field. Each row must produce a state memory entry keyed by `Key`, so an empty key is rejected before merging into state.","triggerScenarios":"Passing `updateStateMemory` as a JSON array where one or more entries lack the `Key` property or have an empty string — e.g. `[{\"Value\":\"x\"}]`.","commonSituations":"User added a state-memory row in the JSON tab but forgot to fill the Key; renamed the column externally; partial copy-paste left a row with only a Value.","solutions":["Ensure every entry in the `updateStateMemory` array has a non-empty `Key` property.","Use the UI tab (updateStateMemoryUI) instead of raw JSON so keys are validated by the form.","Run a preflight check filtering rows without keys before submitting the node config."],"exampleFix":"// before\nnodeData.inputs.updateStateMemory = '[{\"Value\":\"Alice\"}]' // throws [286]\n\n// after\nnodeData.inputs.updateStateMemory = '[{\"Key\":\"userName\",\"Value\":\"Alice\"}]'","handlingStrategy":"validation","validationCode":"function validateStateMemorySchema(schema) {\n  const arr = typeof schema === 'string' ? JSON.parse(schema) : schema\n  if (!Array.isArray(arr)) throw new Error('updateStateMemory must be a JSON array')\n  for (const row of arr) {\n    if (!row.Key) throw new Error(`Row is missing a Key: ${JSON.stringify(row)}`)\n  }\n  return arr\n}\n\nvalidateStateMemorySchema(nodeData.inputs.updateStateMemory)","typeGuard":"function isStateMemoryRow(v): v is { Key: string; Value: unknown } {\n  return v != null && typeof v === 'object' && typeof (v as any).Key === 'string' && (v as any).Key.length > 0\n}","tryCatchPattern":null,"preventionTips":["Prefer the UI grid tab over raw JSON so keys are enforced.","Always fill the Key field before adding another row.","Validate the array with JSON.parse before saving the node."],"tags":["state-memory","configuration","input-validation"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}