{"record":{"id":"8f4704f35aea5c3c","repo":"mem0ai/mem0","slug":"a-valid-postgresql-connection-string-must-be-provi","errorCode":null,"errorMessage":"A valid PostgreSQL connection string must be provided","messagePattern":"A valid PostgreSQL connection string must be provided","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mem0/configs/vector_stores/supabase.py","lineNumber":31,"sourceCode":"class IndexMeasure(str, Enum):\n    COSINE = \"cosine_distance\"\n    L2 = \"l2_distance\"\n    L1 = \"l1_distance\"\n    MAX_INNER_PRODUCT = \"max_inner_product\"\n\n\nclass SupabaseConfig(BaseModel):\n    connection_string: str = Field(..., description=\"PostgreSQL connection string\")\n    collection_name: str = Field(\"mem0\", description=\"Name for the vector collection\")\n    embedding_model_dims: Optional[int] = Field(1536, description=\"Dimensions of the embedding model\")\n    index_method: Optional[IndexMethod] = Field(IndexMethod.AUTO, description=\"Index method to use\")\n    index_measure: Optional[IndexMeasure] = Field(IndexMeasure.COSINE, description=\"Distance measure to use\")\n\n    @model_validator(mode=\"before\")\n    def check_connection_string(cls, values):\n        conn_str = values.get(\"connection_string\")\n        if not conn_str or not conn_str.startswith(\"postgresql://\"):\n            raise ValueError(\"A valid PostgreSQL connection string must be provided\")\n        return values\n\n    @model_validator(mode=\"before\")\n    @classmethod\n    def validate_extra_fields(cls, values: Dict[str, Any]) -> Dict[str, Any]:\n        allowed_fields = set(cls.model_fields.keys())\n        input_fields = set(values.keys())\n        extra_fields = input_fields - allowed_fields\n        if extra_fields:\n            raise ValueError(\n                f\"Extra fields not allowed: {', '.join(extra_fields)}. Please input only the following fields: {', '.join(allowed_fields)}\"\n            )\n        return values\n\n    model_config = ConfigDict(arbitrary_types_allowed=False)\n","sourceCodeStart":13,"sourceCodeEnd":47,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0/configs/vector_stores/supabase.py#L13-L47","documentation":"SupabaseConfig requires connection_string to be a non-empty string starting with 'postgresql://'. The `before` validator reads values.get('connection_string') and raises this ValueError when it is missing, None, empty, or uses a different scheme (e.g. 'postgres://' or the Supabase session pooler string with a different prefix). Validation happens before field coercion, so a wrong scheme fails immediately.","triggerScenarios":"Memory(vector_store={'provider': 'supabase', 'config': {}}) with no connection_string; passing connection_string='postgres://...' (single 'ql' missing) ; passing the Supabase anon key or URL instead of the database connection string.","commonSituations":"Grabbing the 'postgres://...' URI from an older Supabase dashboard or a ORM config (Supabase now exposes both postgresql:// and postgres:// forms); forgetting the connection string entirely; confusing the project REST URL with the DB connection string.","solutions":["Use the full connection string from Supabase Dashboard > Project Settings > Database, in postgresql://... form","If your URI starts with postgres://, either change the prefix to postgresql:// or enable prefix rewriting (e.g. SQLAlchemy's postgresql+psycopg2 prefix handling)","Verify the string is passed under the exact key 'connection_string' in the vector store config dict"],"exampleFix":"# before\nconfig = {\"connection_string\": \"postgres://postgres:pass@db.xyz.supabase.co:5432/postgres\"}\n\n# after\nconfig = {\"connection_string\": \"postgresql://postgres.postgres:pass@aws-0-us-east-1.pooler.supabase.com:6543/postgres\"}","handlingStrategy":"validation","validationCode":"def is_valid_conn(s: str) -> bool:\n    return bool(s) and s.startswith(\"postgresql://\")\n\nif not is_valid_conn(cfg.get(\"connection_string\", \"\")):\n    raise ConfigError(\"connection_string must start with postgresql://\")","typeGuard":"def is_postgresql_dsn(v: object) -> bool:\n    return isinstance(v, str) and v.startswith(\"postgresql://\")","tryCatchPattern":"try:\n    memory = Memory(config=full_config)\nexcept ValueError as e:\n    if \"PostgreSQL connection string\" in str(e):\n        raise ConfigError(\"Fix the Supabase connection string (use postgresql:// form)\") from e\n    raise","preventionTips":["Fetch the connection string from Supabase Dashboard > Database and prefer the pooler URI in postgresql:// form","Normalize postgres:// to postgresql:// at config-load time"],"tags":["pydantic","supabase","postgres","vector-store","config","validation"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}