{"record":{"id":"a987eef8ee4b4cc3","repo":"n8n-io/n8n","slug":"invalid-payload-type","errorCode":null,"errorMessage":"Invalid payload type","messagePattern":"Invalid payload type","errorType":"validation","errorClass":"UserError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/nodes-langchain/nodes/vector_store/VectorStoreInMemory/VectorStoreInMemory.node.ts","lineNumber":166,"sourceCode":"\t\t\t\t\t});\n\n\t\t\t\tlet results = searchOptions;\n\t\t\t\tif (filter) {\n\t\t\t\t\tresults = results.filter((option) => option.name.includes(filter));\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tresults,\n\t\t\t\t};\n\t\t\t},\n\t\t},\n\t\tactionHandler: {\n\t\t\tasync createVectorStore(\n\t\t\t\tthis: ILoadOptionsFunctions,\n\t\t\t\tpayload: string | IDataObject | undefined,\n\t\t\t): Promise<NodeParameterValueType> {\n\t\t\t\tif (!payload || typeof payload === 'string') {\n\t\t\t\t\tthrow new UserError('Invalid payload type');\n\t\t\t\t}\n\n\t\t\t\tconst { name } = payload;\n\n\t\t\t\tconst vectorStoreSingleton = MemoryVectorStoreManager.getInstance(\n\t\t\t\t\t{} as Embeddings, // Real Embeddings are provided when executing the node\n\t\t\t\t\tthis.logger,\n\t\t\t\t);\n\n\t\t\t\tconst memoryKey = name ? (name as string) : DEFAULT_MEMORY_KEY;\n\t\t\t\tawait vectorStoreSingleton.getVectorStore(memoryKey);\n\n\t\t\t\treturn memoryKey;\n\t\t\t},\n\t\t},\n\t},\n\tinsertFields,\n\tloadFields: [warningBanner],","sourceCodeStart":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/nodes-langchain/nodes/vector_store/VectorStoreInMemory/VectorStoreInMemory.node.ts#L148-L184","documentation":"Thrown as a UserError by the In-Memory vector store's `createVectorStore` action handler when the `payload` argument is missing (`undefined`) or a plain string rather than an `IDataObject`. The action handler is invoked from the editor UI to materialize a named in-memory store; it expects an object carrying at least a `name` field.","triggerScenarios":"The UI invokes the action handler with a string (older action payload shape), or with `undefined` because the user submitted the form without the action payload; programmatic invocation of the action handler with a malformed argument.","commonSituations":"Custom UI or another node calling the action handler with the wrong payload type; downgrade/upgrade of editor-ui that changed the action payload contract; test harness invoking the handler without an object.","solutions":["Ensure the action handler is invoked with an `IDataObject` payload (e.g. `{ name: 'myStore' }`).","If a string is genuinely desired, wrap it before calling: `{ name: theString }`.","Update the caller (editor-ui or test) to the current action payload contract."],"exampleFix":"// before\nif (!payload || typeof payload === 'string') {\n  throw new UserError('Invalid payload type');\n}\n\n// after: accept a string by coercing it into the expected shape\nconst source = typeof payload === 'string' ? { name: payload } : payload;\nif (!source || typeof source !== 'object') {\n  throw new UserError('Invalid payload type: expected an object or a string');\n}\nconst { name } = source as IDataObject;","handlingStrategy":"type-guard","validationCode":"// Normalize the payload before validating so callers can pass either shape.\nfunction normalizePayload(payload: string | IDataObject | undefined): IDataObject {\n  if (typeof payload === 'string') return { name: payload };\n  if (payload && typeof payload === 'object') return payload;\n  throw new UserError('Invalid payload type');\n}","typeGuard":"function isActionPayload(value: unknown): value is IDataObject {\n  return typeof value === 'object' && value !== null && !Array.isArray(value);\n}","tryCatchPattern":"// No try/catch needed; this is a synchronous type guard.\nif (!isActionPayload(payload)) {\n  throw new UserError('Invalid payload type');\n}","preventionTips":["Document the expected payload shape at the action-handler boundary.","Have callers construct the object explicitly rather than passing strings.","Add a unit test for both valid and invalid payload shapes."],"tags":["in-memory-vector-store","vector-store","type-validation","user-error","action-handler","langchain"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}