mem0ai/mem0 · error · ValueError

Either 'password' must be provided or 'use_azure_credential'

Error message

Either 'password' must be provided or 'use_azure_credential' must be set to True

What it means

Raised by the AzureMySQL vector store config validator when neither a database password nor Azure managed identity is configured. Mem0 requires an explicit authentication path before it will build an Azure MySQL connection, unless you hand it a pre-built connection_pool. It is a Pydantic model validator (mode='before') that runs at config construction time.

Source

Thrown at mem0/configs/vector_stores/azure_mysql.py:56

                f"Invalid collection_name: {v!r}. Must start with a letter or underscore and "
                "contain only letters, digits, and underscores."
            )
        return v

    @model_validator(mode="before")
    @classmethod
    def check_auth(cls, values: Dict[str, Any]) -> Dict[str, Any]:
        """Validate authentication parameters."""
        # If connection_pool is provided, skip validation
        if values.get("connection_pool") is not None:
            return values

        use_azure_credential = values.get("use_azure_credential", False)
        password = values.get("password")

        # Either password or Azure credential must be provided
        if not use_azure_credential and not password:
            raise ValueError(
                "Either 'password' must be provided or 'use_azure_credential' must be set to True"
            )

        return values

    @model_validator(mode="before")
    @classmethod
    def check_required_fields(cls, values: Dict[str, Any]) -> Dict[str, Any]:
        """Validate required fields."""
        # If connection_pool is provided, skip validation of individual parameters
        if values.get("connection_pool") is not None:
            return values

        required_fields = ["host", "user", "database"]
        missing_fields = [field for field in required_fields if not values.get(field)]

        if missing_fields:
            raise ValueError(

View on GitHub (pinned to 001c235229)

Solutions

  1. Set use_azure_credential=True in the config to use Azure managed identity (DefaultAzureCredential) instead of a password
  2. Provide the 'password' field directly in the vector store config dict
  3. Pass a pre-built 'connection_pool' object (e.g. mysql.connector.pooling.MySQLConnectionPool), which skips all auth validation
  4. Verify the config dict keys actually reach the validator (typos like 'passwd' or 'pass' silently drop the password)

Example fix

// before
config = {
    "vector_store": {
        "provider": "azure_mysql",
        "config": {"host": "x.mysql.database.azure.com", "user": "u", "database": "db"}
    }
}

# after
config = {
    "vector_store": {
        "provider": "azure_mysql",
        "config": {
            "host": "x.mysql.database.azure.com",
            "user": "u",
            "database": "db",
            "use_azure_credential": True
        }
    }
}
Defensive patterns

Strategy: validation

Validate before calling

def validate_azure_mysql_auth(cfg: dict) -> None:
    if cfg.get("connection_pool") is not None:
        return
    if not cfg.get("use_azure_credential", False) and not cfg.get("password"):
        raise RuntimeError("azure_mysql config needs 'password' or use_azure_credential=True")

Type guard

def has_azure_mysql_auth(cfg: dict) -> bool:
    return cfg.get("connection_pool") is not None or bool(cfg.get("use_azure_credential") or cfg.get("password"))

Try / catch

from pydantic import ValidationError
try:
    AzureMySQLConfig(**cfg)
except ValidationError as e:
    if "use_azure_credential" in str(e):
        # resolve credentials / switch to managed identity, then retry construction
        ...

Prevention

When it happens

Trigger: Instantiating AzureMySQLConfig (or passing vector_store config of type 'azure_mysql' to Memory.add) with no 'password' key and use_azure_credential unset/False, while also not supplying 'connection_pool'. Any falsy password (None, empty string) triggers it.

Common situations: Copying an example config that omits credentials and intending to use Azure managed identity but forgetting use_azure_credential=True; relying on environment variables that the config never reads; migrating from a config that injected a connection_pool programmatically.

Related errors


AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15). Data as JSON: /api/errors/734085b7100d1129. Report an issue: GitHub.