{"record":{"id":"41659d9d3d84798c","repo":"FlowiseAI/Flowise","slug":"e-41659d","errorCode":null,"errorMessage":"${e}","messagePattern":"\\$\\{e\\}","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/vectorstores/Postgres/Postgres.ts","lineNumber":293,"sourceCode":"                        }\n                    })\n\n                    return res\n                } else {\n                    if (_batchSize) {\n                        const batchSize = parseInt(_batchSize, 10)\n                        for (let i = 0; i < finalDocs.length; i += batchSize) {\n                            const batch = finalDocs.slice(i, i + batchSize)\n                            await vectorStoreDriver.fromDocuments(batch)\n                        }\n                    } else {\n                        await vectorStoreDriver.fromDocuments(finalDocs)\n                    }\n\n                    return { numAdded: finalDocs.length, addedDocs: finalDocs }\n                }\n            } catch (e) {\n                throw new Error(e)\n            }\n        },\n        async delete(nodeData: INodeData, ids: string[], options: ICommonObject): Promise<void> {\n            const vectorStoreDriver: VectorStoreDriver = Postgres_VectorStores.getDriverFromConfig(nodeData, options)\n            const tableName = getTableName(nodeData)\n            const recordManager = nodeData.inputs?.recordManager\n\n            const vectorStore = await vectorStoreDriver.instanciate()\n\n            try {\n                if (recordManager) {\n                    const vectorStoreName = tableName\n                    await recordManager.createSchema()\n                    ;(recordManager as any).namespace = (recordManager as any).namespace + '_' + vectorStoreName\n                    const filterKeys: ICommonObject = {}\n                    if (options.docId) {\n                        filterKeys.docId = options.docId\n                    }","sourceCodeStart":275,"sourceCodeEnd":311,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/vectorstores/Postgres/Postgres.ts#L275-L311","documentation":"Generic catch-all in the Postgres node's add path wrapping batched or single `vectorStoreDriver.fromDocuments(...)` calls. Any PGVector/TypeORM failure (connection, table creation, dimension, duplicate) is re-thrown as `new Error(e)`, flattening the original error into a string.","triggerScenarios":"Postgres unreachable; auth failure; `pgvector` extension not installed; table creation permission denied; vector dimension mismatch with the column type; TypeORM/PGVector driver-specific error; batch size parse error.","commonSituations":"Connection string points at wrong host/port; `pgvector` extension not enabled on the DB; user lacks CREATE TABLE; embedding model changed dimension without migrating the column; `additionalConfig` JSON malformed.","solutions":["Read the flattened message for the driver-specific reason (connection, extension, dimension).","Verify Postgres connectivity and credentials.","Ensure `CREATE EXTENSION IF NOT EXISTS vector;` has been run and the user can use it.","Confirm the table's vector column dimension matches the embedding model.","Re-wrap preserving the original error (see fix)."],"exampleFix":"// before\n} catch (e) {\n    throw new Error(e)\n}\n// after — preserve cause\n} catch (e) {\n    throw e instanceof Error ? e : new Error(String(e))\n}","handlingStrategy":"try-catch","validationCode":"// preflight: connectivity + pgvector extension + dimension\nconst pool = new Pool({ connectionString })\nconst ext = await pool.query(\"SELECT 1 FROM pg_extension WHERE extname='vector'\")\nif (!ext.rowCount) throw new Error('pgvector extension not installed')\nconst dim = (await embeddings.embedQuery('test')).length\nif (tableVectorDim && dim !== tableVectorDim) throw new Error(`dim ${dim} != column ${tableVectorDim}`)\nawait pool.end()","typeGuard":"function isPgConnectionError(e: unknown): boolean {\n  const msg = e instanceof Error ? e.message : String(e)\n  return /ECONNREFUSED|password authentication|no pg_hba/i.test(msg)\n}","tryCatchPattern":"try {\n  for (let i = 0; i < finalDocs.length; i += batchSize) {\n    await vectorStoreDriver.fromDocuments(finalDocs.slice(i, i + batchSize))\n  }\n} catch (e) {\n  throw e instanceof Error ? e : new Error(`Postgres fromDocuments failed: ${String(e)}`)\n}","preventionTips":["Run `CREATE EXTENSION IF NOT EXISTS vector;` and grant usage.","Keep the table's vector column dimension aligned with the embedding model.","Grant CREATE TABLE to the connecting user.","Avoid `throw new Error(e)`; rethrow the original."],"tags":["postgres","pgvector","error-handling","stack-trace"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}