{"record":{"id":"c0b988328026fc37","repo":"FlowiseAI/Flowise","slug":"e-c0b988","errorCode":null,"errorMessage":"${e}","messagePattern":"\\$\\{e\\}","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/vectorstores/MongoDBAtlas/MongoDBAtlas.ts","lineNumber":159,"sourceCode":"                    finalDocs.push(document)\n                }\n            }\n\n            try {\n                if (!textKey || textKey === '') textKey = 'text'\n                if (!embeddingKey || embeddingKey === '') embeddingKey = 'embedding'\n\n                const mongoDBAtlasVectorSearch = new MongoDBAtlasVectorSearch(embeddings, {\n                    connectionDetails: { mongoDBConnectUrl, databaseName, collectionName },\n                    indexName,\n                    textKey,\n                    embeddingKey\n                })\n                await mongoDBAtlasVectorSearch.addDocuments(finalDocs)\n\n                return { numAdded: finalDocs.length, addedDocs: finalDocs }\n            } catch (e) {\n                throw new Error(e)\n            }\n        }\n    }\n\n    async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {\n        const credentialData = await getCredentialData(nodeData.credential ?? '', options)\n        const databaseName = nodeData.inputs?.databaseName as string\n        const collectionName = nodeData.inputs?.collectionName as string\n        const indexName = nodeData.inputs?.indexName as string\n        let textKey = nodeData.inputs?.textKey as string\n        let embeddingKey = nodeData.inputs?.embeddingKey as string\n        const embeddings = nodeData.inputs?.embeddings as Embeddings\n        const mongoMetadataFilter = nodeData.inputs?.mongoMetadataFilter as object\n\n        let mongoDBConnectUrl = getCredentialParam('mongoDBConnectUrl', credentialData, nodeData)\n\n        const mongoDbFilter: MongoDBAtlasVectorSearch['FilterType'] = {}\n","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/vectorstores/MongoDBAtlas/MongoDBAtlas.ts#L141-L177","documentation":"A generic catch-all in the MongoDB Atlas vector store node's `addDocuments` path: any exception thrown while constructing `MongoDBAtlasVectorSearch` or calling `addDocuments` is re-wrapped via `throw new Error(e)`. Because `new Error(e)` coerces a non-string to its string form, an original `Error` loses its stack trace and name, and the message becomes the original error's `.toString()` (e.g. `Error: connection timeout`).","triggerScenarios":"MongoDB connection failure (bad URI, network blocked, IP not allow-listed on Atlas); the search index does not exist or is not ready; `addDocuments` violates a schema validation rule; embedding dimension does not match the vector field definition in the Atlas search index.","commonSituations":"Atlas cluster IP allow-list does not include the host; `mongoDBConnectUrl` credential stale or rotated; vector search index still building; embedding model changed without recreating the index definition.","solutions":["Read the wrapped message to get the MongoDB driver's underlying reason (auth, timeout, index).","Verify the Atlas cluster's network access includes the current host IP.","Confirm the vector search index exists and its `dimensions` match the embedding model output.","Re-wrap with `Error`-preserving code (see fix) so future failures retain their stack.","Rotate/re-check the `mongoDBConnectUrl` credential if auth is the cause."],"exampleFix":"// before\n} catch (e) {\n    throw new Error(e)\n}\n// after — preserve the original error chain\n} catch (e) {\n    throw e instanceof Error ? e : new Error(String(e))\n}","handlingStrategy":"try-catch","validationCode":"// preflight: validate connection + index readiness\nconst client = new MongoClient(mongoDBConnectUrl)\nawait client.connect()\nconst coll = client.db(databaseName).collection(collectionName)\nconst indexes = await coll.listSearchIndexes({ name: indexName }).toArray()\nif (!indexes.length || indexes[0].status !== 'READY') {\n  throw new Error(`Atlas search index '${indexName}' not ready`)\n}","typeGuard":"function isMongoError(e: unknown): e is { code: string; message: string } {\n  return typeof e === 'object' && e !== null && 'code' in e && 'message' in e\n}","tryCatchPattern":"try {\n  await mongoDBAtlasVectorSearch.addDocuments(finalDocs)\n} catch (e) {\n  // preserve original error\n  throw e instanceof Error ? e : new Error(String(e))\n}","preventionTips":["Add the host IP to the Atlas allow-list before connecting.","Confirm the search index exists and is READY before writing.","Keep the embedding dimension aligned with the index definition.","Avoid `throw new Error(e)` — rethrow the original to preserve the stack."],"tags":["mongodb-atlas","error-handling","connection","stack-trace"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}