n8n-io/n8n · error · UserError
Invalid payload type
Error message
Invalid payload type
What it means
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.
Source
Thrown at packages/@n8n/nodes-langchain/nodes/vector_store/VectorStoreInMemory/VectorStoreInMemory.node.ts:166
});
let results = searchOptions;
if (filter) {
results = results.filter((option) => option.name.includes(filter));
}
return {
results,
};
},
},
actionHandler: {
async createVectorStore(
this: ILoadOptionsFunctions,
payload: string | IDataObject | undefined,
): Promise<NodeParameterValueType> {
if (!payload || typeof payload === 'string') {
throw new UserError('Invalid payload type');
}
const { name } = payload;
const vectorStoreSingleton = MemoryVectorStoreManager.getInstance(
{} as Embeddings, // Real Embeddings are provided when executing the node
this.logger,
);
const memoryKey = name ? (name as string) : DEFAULT_MEMORY_KEY;
await vectorStoreSingleton.getVectorStore(memoryKey);
return memoryKey;
},
},
},
insertFields,
loadFields: [warningBanner],View on GitHub (pinned to 5ac6606e81)
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.
Example fix
// before
if (!payload || typeof payload === 'string') {
throw new UserError('Invalid payload type');
}
// after: accept a string by coercing it into the expected shape
const source = typeof payload === 'string' ? { name: payload } : payload;
if (!source || typeof source !== 'object') {
throw new UserError('Invalid payload type: expected an object or a string');
}
const { name } = source as IDataObject; Defensive patterns
Strategy: type-guard
Validate before calling
// Normalize the payload before validating so callers can pass either shape.
function normalizePayload(payload: string | IDataObject | undefined): IDataObject {
if (typeof payload === 'string') return { name: payload };
if (payload && typeof payload === 'object') return payload;
throw new UserError('Invalid payload type');
} Type guard
function isActionPayload(value: unknown): value is IDataObject {
return typeof value === 'object' && value !== null && !Array.isArray(value);
} Try / catch
// No try/catch needed; this is a synchronous type guard.
if (!isActionPayload(payload)) {
throw new UserError('Invalid payload type');
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Collection must be a string
- Parameter ${key} must be a string
- Error: No JSON string provided.
- Invalid Qdrant URL: ${url}. Please provide a valid URL with
- Failed to initialize Chroma collection
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/a987eef8ee4b4cc3.
Report an issue: GitHub.