n8n-io/n8n · error · NodeOperationError
Database name must be provided either in credentials or in…
Error message
Database name must be provided either in credentials or in node parameters
What it means
MongoDB chat-memory node builds its connection either from a connection string or from discrete fields; after resolution, no database name is available — neither the node's databaseName parameter nor the credential's database field is set, and the chat history collection cannot be chosen.
Solutions
- Set the database name in the node parameters
- Or fill in the database field on the MongoDB credential
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at packages/@n8n/nodes-langchain/nodes/memory/MemoryMongoDbChat/MemoryMongoDbChat.node.ts:126 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/aec27c9e00faf771.
Report an issue: GitHub.
Appendix: source
Thrown at packages/@n8n/nodes-langchain/nodes/memory/MemoryMongoDbChat/MemoryMongoDbChat.node.ts:126
} else {
// Build connection string from individual fields
const host = credentials.host;
const port = credentials.port;
const user = credentials.user ? encodeURIComponent(credentials.user) : '';
const password = credentials.password ? encodeURIComponent(credentials.password) : '';
const authString = user && password ? `${user}:${password}@` : '';
const tls = credentials.tls;
connectionString = `mongodb://${authString}${host}:${port}/?appname=n8n`;
if (tls) {
connectionString += '&ssl=true';
}
dbName = databaseName || credentials.database;
}
if (!dbName) {
throw new NodeOperationError(
this.getNode(),
'Database name must be provided either in credentials or in node parameters',
);
}
const client = new MongoClient(connectionString, {
minPoolSize: 0,
maxPoolSize: 1,
maxIdleTimeMS: 30000,
});
try {
await client.connect();
const db = client.db(dbName);
const collection = db.collection(collectionName);
const mongoDBChatHistory = new MongoDBChatMessageHistory({View on GitHub (pinned to 5ac6606e81)