mem0ai/mem0 · error · ValueError
A valid PostgreSQL connection string must be provided
Error message
A valid PostgreSQL connection string must be provided
What it means
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.
Source
Thrown at mem0/configs/vector_stores/supabase.py:31
class IndexMeasure(str, Enum):
COSINE = "cosine_distance"
L2 = "l2_distance"
L1 = "l1_distance"
MAX_INNER_PRODUCT = "max_inner_product"
class SupabaseConfig(BaseModel):
connection_string: str = Field(..., description="PostgreSQL connection string")
collection_name: str = Field("mem0", description="Name for the vector collection")
embedding_model_dims: Optional[int] = Field(1536, description="Dimensions of the embedding model")
index_method: Optional[IndexMethod] = Field(IndexMethod.AUTO, description="Index method to use")
index_measure: Optional[IndexMeasure] = Field(IndexMeasure.COSINE, description="Distance measure to use")
@model_validator(mode="before")
def check_connection_string(cls, values):
conn_str = values.get("connection_string")
if not conn_str or not conn_str.startswith("postgresql://"):
raise ValueError("A valid PostgreSQL connection string must be provided")
return values
@model_validator(mode="before")
@classmethod
def validate_extra_fields(cls, values: Dict[str, Any]) -> Dict[str, Any]:
allowed_fields = set(cls.model_fields.keys())
input_fields = set(values.keys())
extra_fields = input_fields - allowed_fields
if extra_fields:
raise ValueError(
f"Extra fields not allowed: {', '.join(extra_fields)}. Please input only the following fields: {', '.join(allowed_fields)}"
)
return values
model_config = ConfigDict(arbitrary_types_allowed=False)
View on GitHub (pinned to 001c235229)
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
Example fix
# before
config = {"connection_string": "postgres://postgres:pass@db.xyz.supabase.co:5432/postgres"}
# after
config = {"connection_string": "postgresql://postgres.postgres:pass@aws-0-us-east-1.pooler.supabase.com:6543/postgres"} Defensive patterns
Strategy: validation
Validate before calling
def is_valid_conn(s: str) -> bool:
return bool(s) and s.startswith("postgresql://")
if not is_valid_conn(cfg.get("connection_string", "")):
raise ConfigError("connection_string must start with postgresql://") Type guard
def is_postgresql_dsn(v: object) -> bool:
return isinstance(v, str) and v.startswith("postgresql://") Try / catch
try:
memory = Memory(config=full_config)
except ValueError as e:
if "PostgreSQL connection string" in str(e):
raise ConfigError("Fix the Supabase connection string (use postgresql:// form)") from e
raise Prevention
- Fetch the connection string from Supabase Dashboard > Database and prefer the pooler URI in postgresql:// form
- Normalize postgres:// to postgresql:// at config-load time
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Extra fields not allowed: {', '.join(extra_fields)}. Please
- Extra fields not allowed: {', '.join(extra_fields)}. Please
- Extra fields not allowed: {', '.join(extra_fields)}. Please
- Extra fields not allowed: {', '.join(extra_fields)}. Please
- Extra fields not allowed: {', '.join(extra_fields)}. Please
AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15).
Data as JSON: /api/errors/8f4704f35aea5c3c.
Report an issue: GitHub.