{"record":{"id":"507f4538753b6b31","repo":"mem0ai/mem0","slug":"embedding-model-dims-must-be-provided-either-durin","errorCode":null,"errorMessage":"embedding_model_dims must be provided either during initialization or when creating collection","messagePattern":"embedding_model_dims must be provided either during initialization or when creating collection","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mem0/vector_stores/supabase.py","lineNumber":85,"sourceCode":"            # For single filter, keep the simple format\n            key, value = next(iter(filters.items()))\n            return {key: {\"$eq\": value}}\n\n        # For multiple filters, use $and clause\n        return {\"$and\": [{key: {\"$eq\": value}} for key, value in filters.items()]}\n\n    def create_col(self, embedding_model_dims: Optional[int] = None) -> None:\n        \"\"\"\n        Create a new collection with vector support.\n        Will also initialize vector search index.\n\n        Args:\n            embedding_model_dims (int, optional): Dimension of the embedding vector.\n                If not provided, uses the dimension specified in initialization.\n        \"\"\"\n        dims = embedding_model_dims or self.embedding_model_dims\n        if not dims:\n            raise ValueError(\n                \"embedding_model_dims must be provided either during initialization or when creating collection\"\n            )\n\n        logger.info(f\"Creating new collection: {self.collection_name}\")\n        try:\n            self.collection = self.db.get_or_create_collection(name=self.collection_name, dimension=dims)\n            self.collection.create_index(method=self.index_method.value, measure=self.index_measure.value)\n            logger.info(f\"Successfully created collection {self.collection_name} with dimension {dims}\")\n        except Exception as e:\n            logger.error(f\"Failed to create collection: {str(e)}\")\n            raise\n\n    def insert(\n        self, vectors: List[List[float]], payloads: Optional[List[dict]] = None, ids: Optional[List[str]] = None\n    ):\n        \"\"\"\n        Insert vectors into the collection.\n","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0/vector_stores/supabase.py#L67-L103","documentation":"Raised in Supabase.create_col when the effective dimension is falsy: `dims = embedding_model_dims or self.embedding_model_dims` evaluates to None/0. A pgvector collection via vecs needs an explicit vector dimension to build its index, so mem0 refuses to create one with unknown dims. Note that because `or` is used, a dims value of 0 is also treated as missing.","triggerScenarios":"Constructing the Supabase store without embedding_model_dims in config and then calling create_col() with no argument; passing embedding_model_dims=0; a config dict where the embedding provider section is absent so mem0 never propagates dims into the vector store config.","commonSituations":"Minimal vector_store config that relies on defaults which don't exist for dims; swapping embedding providers (e.g. 1536-dim OpenAI to a custom model) without updating the dims; copy-paste config examples that omit the field.","solutions":["Add embedding_model_dims to the vector store config matching your embedder: `\"config\": {\"collection_name\": \"mem\", \"embedding_model_dims\": 1536}`.","Or pass it per call: `store.create_col(embedding_model_dims=1536)`.","If you use a custom embedder, set dims to its actual output width — mismatched dims fail later at insert time with a pgvector dimension error."],"exampleFix":"# before\nmemory = Memory.from_config({\n    \"vector_store\": {\"provider\": \"supabase\", \"config\": {\"collection_name\": \"mem\"}}\n})\nstore.create_col()  # ValueError\n\n# after\nmemory = Memory.from_config({\n    \"embedder\": {\"provider\": \"openai\", \"config\": {\"model\": \"text-embedding-3-small\"}},\n    \"vector_store\": {\n        \"provider\": \"supabase\",\n        \"config\": {\"collection_name\": \"mem\", \"embedding_model_dims\": 1536},\n    },\n})","handlingStrategy":"validation","validationCode":"EMBEDDER_DIMS = {\"text-embedding-3-small\": 1536, \"text-embedding-3-large\": 3072}\nmodel = \"text-embedding-3-small\"\ndims = EMBEDDER_DIMS.get(model)\nassert dims, f\"Unknown dims for embedder {model}; set vector_store.config.embedding_model_dims explicitly\"","typeGuard":null,"tryCatchPattern":"try:\n    store.create_col()\nexcept ValueError as e:\n    if \"embedding_model_dims\" in str(e):\n        store.create_col(embedding_model_dims=1536)  # supply explicitly and retry\n    else:\n        raise","preventionTips":["Always pair an embedder config with an explicit embedding_model_dims in the vector store config.","Keep a single source of truth for the embedding model per environment so dims cannot drift.","Never rely on create_col() defaults for Supabase — there are none for dimensions."],"tags":["configuration","supabase","embeddings","dimension-mismatch","vector-store"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}