mem0ai/mem0 · error · ValueError
Missing required fields: {', '.join(missing_fields)}. These
Error message
Missing required fields: {', '.join(missing_fields)}. These fields are required when not using a pre-configured connection_pool. What it means
Raised by the AzureMySQL config validator when required connection fields are missing. Host, user, and database are mandatory unless you supply a pre-configured connection_pool that already encapsulates connectivity. It fires during Pydantic model validation, before any network call is attempted.
Source
Thrown at mem0/configs/vector_stores/azure_mysql.py:74
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(
f"Missing required fields: {', '.join(missing_fields)}. "
f"These fields are required when not using a pre-configured connection_pool."
)
return values
@model_validator(mode="before")
@classmethod
def validate_extra_fields(cls, values: Dict[str, Any]) -> Dict[str, Any]:
"""Validate that no extra fields are provided."""
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)}. "
f"Please input only the following fields: {', '.join(allowed_fields)}"View on GitHub (pinned to 001c235229)
Solutions
- Add the missing field(s) named in the error message to the config dict (exact names: host, user, database)
- If you already manage connections yourself, pass 'connection_pool' to skip field validation entirely
- Check spelling and nesting of keys against the error's missing-field list
- Add a startup assertion or schema check for the config file so this fails loudly in CI, not at runtime
Example fix
# before AzureMySQLConfig(user="admin", database="mem0") # after AzureMySQLConfig(host="myserver.mysql.database.azure.com", user="admin", database="mem0", password=os.environ["MYSQL_PWD"])
Defensive patterns
Strategy: validation
Validate before calling
REQUIRED = ("host", "user", "database")
def validate_azure_mysql_fields(cfg: dict) -> None:
if cfg.get("connection_pool") is not None:
return
missing = [k for k in REQUIRED if not cfg.get(k)]
if missing:
raise RuntimeError(f"azure_mysql config missing: {', '.join(missing)}") Type guard
def is_complete_azure_mysql_cfg(cfg: dict) -> bool:
return cfg.get("connection_pool") is not None or all(cfg.get(k) for k in ("host", "user", "database")) Try / catch
from pydantic import ValidationError
try:
AzureMySQLConfig(**cfg)
except ValidationError as e:
if "Missing required fields" in str(e):
# surface to config author / fail deployment
... Prevention
- Validate config dicts against a required-key list in CI
- Load configs from typed sources (pydantic settings) so missing keys fail at load time with clear errors
- Keep provider config nesting uniform across environments
When it happens
Trigger: Constructing AzureMySQLConfig without 'connection_pool' and with any of 'host', 'user', or 'database' absent, None, or empty string. Commonly hit when the config dict is nested one level too shallow or keys are misspelled.
Common situations: YAML/JSON config where the connection block was accidentally flattened into the parent; typos ('hostname' instead of 'host'); partial configs left over from switching providers; CI using a different template than local dev.
Related errors
- Either 'password' must be provided or 'use_azure_credential'
- Extra fields not allowed: {', '.join(extra_fields)}. Please
- Extra fields not allowed: {', '.join(extra_fields)}. Please
- Both 'username' and 'password' must be provided together for
- Either 'contact_points' or 'secure_connect_bundle' must be p
AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15).
Data as JSON: /api/errors/f333d93eeb8a57e7.
Report an issue: GitHub.