{"record":{"id":"d64aa4ca18b43f70","repo":"conductor-oss/conductor","slug":"embeddings-must-be-of-dimensions-embeddingdimen","errorCode":null,"errorMessage":"Embeddings must be of dimensions : <embeddingDimensions>","messagePattern":"Embeddings must be of dimensions : <embeddingDimensions>","errorType":"validation","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"ai/src/main/java/org/conductoross/conductor/ai/vectordb/postgres/PostgresVectorDB.java","lineNumber":192,"sourceCode":"                    \"Error encountered while updating embeddings as : {}\",\n                    exception.getMessage(),\n                    exception);\n            throw new RuntimeException(exception);\n        }\n    }\n\n    private int upsertEmbeddings(\n            String namespace,\n            String id,\n            String parentDocId,\n            String doc,\n            List<Float> embeddings,\n            Map<String, Object> metadata,\n            Connection conn) {\n        final int embeddingDimensions =\n                config.getDimensions() != null ? config.getDimensions() : 256;\n        if (embeddingDimensions != embeddings.size()) {\n            throw new RuntimeException(\"Embeddings must be of dimensions : \" + embeddingDimensions);\n        }\n        String tableName =\n                config.getTablePrefix() != null\n                        ? config.getTablePrefix() + \"_\" + namespace\n                        : namespace;\n        String UPSERT_QUERY =\n                \"INSERT INTO \"\n                        + tableName\n                        + \" AS n (id, parent_doc_id, embedding, doc, metadata) \"\n                        + \"VALUES (?, ?, ?, ?, ?) \"\n                        + \"ON CONFLICT (id) DO UPDATE SET parent_doc_id = ?, embedding = ?, doc = ?, metadata = ? WHERE n.id = ?\";\n        log.debug(\"Executing upsert query: {}\", UPSERT_QUERY);\n        log.debug(\n                \"Upserting document with id: {}, parentDocId: {}, doc length: {}, embedding dimensions: {}\",\n                id,\n                parentDocId,\n                doc.length(),\n                embeddings.size());","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/conductor-oss/conductor/blob/cf7c3e4a8adfb158be778ab1ec525323c363cd3a/ai/src/main/java/org/conductoross/conductor/ai/vectordb/postgres/PostgresVectorDB.java#L174-L210","documentation":"Thrown as a plain RuntimeException by PostgresVectorDB.upsertEmbeddings when the provided embeddings list size does not equal the configured embedding dimensions (default 256, from config.getDimensions()). The pgvector column has a fixed dimension, so a mismatched vector cannot be inserted and would fail at the DB anyway; this guard fails early with a clear message.","triggerScenarios":"Upserting embeddings whose length differs from config.getDimensions() (or 256 if unset). Commonly a model/dimension mismatch: e.g. a 1536-dim OpenAI embedding written into a 256-dim index, or a 384-dim MiniLM into a 1536-dim index.","commonSituations":"Switched embedding model without updating conductor.vectordb.postgres.dimensions; mixed models writing to the same index; dimensions config left at default 256 while using a model with a different output size; chunking code corrupting the vector length.","solutions":["Align config.getDimensions() (conductor.vectordb.postgres.dimensions) with the embedding model's output dimension.","Regenerate embeddings with the model whose dimension matches the index, or recreate the index/table at the new dimension.","Verify the embedding generation step uses the same model/dimensions setting as the index.","Ensure no other producer writes a different-dimension vector to the same namespace."],"exampleFix":"// before\n# config: conductor.vectordb.postgres.dimensions=256\n# but model outputs 1536\n// after\nconductor.vectordb.postgres.dimensions=1536\n# (and recreate the pgvector table/column at the new dimension)","handlingStrategy":"validation","validationCode":"// Match the vector dimension to config before upsert\nint dim = config.getDimensions() != null ? config.getDimensions() : 256;\nif (embeddings.size() != dim) {\n    throw new IllegalArgumentException(\"expected \" + dim + \" dims, got \" + embeddings.size());\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pin conductor.vectordb.postgres.dimensions to the embedding model's output size.","Use a single embedding model per index.","Recreate the pgvector table when changing dimensions."],"tags":["postgres","vectordb","embeddings","validation","dimension-mismatch"],"backgroundTag":null,"analyzedSha":"cf7c3e4a8adfb158be778ab1ec525323c363cd3a","analyzedAt":"2026-08-14T03:33:19.897Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}