{"record":{"id":"88c7c6bc3785461d","repo":"n8n-io/n8n","slug":"error-error-message","errorCode":null,"errorMessage":"Error: ${error.message}","messagePattern":"Error: (.+?)","errorType":"exception","errorClass":"NodeOperationError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/nodes-langchain/nodes/vector_store/VectorStoreMongoDBAtlas/VectorStoreMongoDBAtlas.node.ts","lineNumber":210,"sourceCode":"\n/**\n * Get all the collection in the database.\n * @param this The load options context.\n * @returns The list of collections.\n */\nexport async function getCollections(this: ILoadOptionsFunctions) {\n\tconst client = await createMongoClient(this, this.getNode().typeVersion);\n\ttry {\n\t\tconst db = await getDatabase(this, client);\n\t\tconst collections = await db.listCollections().toArray();\n\t\tconst results = collections.map((collection) => ({\n\t\t\tname: collection.name,\n\t\t\tvalue: collection.name,\n\t\t}));\n\n\t\treturn { results };\n\t} catch (error) {\n\t\tthrow new NodeOperationError(this.getNode(), `Error: ${error.message}`);\n\t} finally {\n\t\tvoid client.close().catch(() => {});\n\t}\n}\n\n/**\n * Get a parameter from the context.\n * @param key - The key of the parameter.\n * @param context - The context.\n * @param itemIndex - The index.\n * @returns The value.\n */\nexport function getParameter(key: string, context: IFunctionsContext, itemIndex: number): string {\n\tconst value = context.getNodeParameter(key, itemIndex, '', {\n\t\textractValue: true,\n\t}) as string;\n\tif (typeof value !== 'string') {\n\t\tthrow new NodeOperationError(context.getNode(), `Parameter ${key} must be a string`);","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/nodes-langchain/nodes/vector_store/VectorStoreMongoDBAtlas/VectorStoreMongoDBAtlas.node.ts#L192-L228","documentation":"Catch-all NodeOperationError in the MongoDB Atlas vector store's `getCollections` load-options function. It runs when the user opens the collection dropdown in the UI and any step — `createMongoClient`, `getDatabase`, or `db.listCollections().toArray()` — throws. The original error message is appended.","triggerScenarios":"Listing collections against a MongoDB Atlas cluster that is unreachable, paused, or whose connection string has the wrong password; the cluster's network access list does not include the n8n host IP; a long-running listCollections call timing out.","commonSituations":"Atlas M0 free tier paused or hibernating; IP not in the Atlas allow-list; password rotated in Atlas but n8n credential not updated; SRV connection string with a typo; user lacks `listCollections` privilege.","solutions":["In Atlas, add the n8n host's public IP to Network Access (or allow `0.0.0.0/0` for testing).","Confirm the cluster is not paused and the connection string is correct.","Verify the database user has at least `read` on the target database.","Re-enter the password in the n8n credential if it was recently rotated."],"exampleFix":"// before\n} catch (error) {\n  throw new NodeOperationError(this.getNode(), `Error: ${error.message}`);\n} finally {\n  void client.close().catch(() => {});\n}\n\n// after: classify the common auth/network cases for the user\n} catch (error) {\n  const msg = error instanceof Error ? error.message : String(error);\n  const hint = /authentication failed/i.test(msg)\n    ? 'Check the database user and password in Atlas.'\n    : /ENOTFOUND|ETIMEDOUT|ECONNREFUSED/.test(msg)\n      ? 'Check the connection string and Atlas Network Access list.'\n      : 'See the Atlas cluster logs for details.';\n  throw new NodeOperationError(this.getNode(), `Error: ${msg}`, { description: hint });\n} finally {\n  void client.close().catch(() => {});\n}","handlingStrategy":"validation","validationCode":"// Validate Atlas reachability and IP allow-listing before the workflow runs.\nasync function assertAtlasReachable(uri: string): Promise<void> {\n  const client = new MongoClient(uri, { serverSelectionTimeoutMS: 5000 });\n  try { await client.db().admin().ping(); } finally { await client.close().catch(() => {}); }\n}","typeGuard":"function classifyMongoError(error: unknown): 'auth' | 'network' | 'unknown' {\n  if (!(error instanceof Error)) return 'unknown';\n  const m = error.message;\n  if (/authentication failed|bad auth/i.test(m)) return 'auth';\n  if (/ENOTFOUND|ETIMEDOUT|ECONNREFUSED/.test(m)) return 'network';\n  return 'unknown';\n}","tryCatchPattern":"try {\n  const db = await getDatabase(this, client);\n  return { results: (await db.listCollections().toArray()).map((c) => ({ name: c.name, value: c.name })) };\n} catch (error) {\n  const bucket = classifyMongoError(error);\n  throw new NodeOperationError(this.getNode(), `Error: ${(error as Error).message}`, {\n    description: bucket === 'auth' ? 'Check the database user and password.'\n      : bucket === 'network' ? 'Check the connection string and Atlas Network Access list.'\n      : 'See Atlas cluster logs.',\n  });\n} finally {\n  void client.close().catch(() => {});\n}","preventionTips":["Add the n8n host IP to Atlas Network Access when deploying.","Verify the cluster is not paused before running listCollections.","Grant the database user at least `read` on the target database."],"tags":["mongodb-atlas","vector-store","load-options","catch-all","node-operation-error","langchain"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}