{"record":{"id":"734085b7100d1129","repo":"mem0ai/mem0","slug":"either-password-must-be-provided-or-use-azure-c","errorCode":null,"errorMessage":"Either 'password' must be provided or 'use_azure_credential' must be set to True","messagePattern":"Either 'password' must be provided or 'use_azure_credential' must be set to True","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mem0/configs/vector_stores/azure_mysql.py","lineNumber":56,"sourceCode":"                f\"Invalid collection_name: {v!r}. Must start with a letter or underscore and \"\n                \"contain only letters, digits, and underscores.\"\n            )\n        return v\n\n    @model_validator(mode=\"before\")\n    @classmethod\n    def check_auth(cls, values: Dict[str, Any]) -> Dict[str, Any]:\n        \"\"\"Validate authentication parameters.\"\"\"\n        # If connection_pool is provided, skip validation\n        if values.get(\"connection_pool\") is not None:\n            return values\n\n        use_azure_credential = values.get(\"use_azure_credential\", False)\n        password = values.get(\"password\")\n\n        # Either password or Azure credential must be provided\n        if not use_azure_credential and not password:\n            raise ValueError(\n                \"Either 'password' must be provided or 'use_azure_credential' must be set to True\"\n            )\n\n        return values\n\n    @model_validator(mode=\"before\")\n    @classmethod\n    def check_required_fields(cls, values: Dict[str, Any]) -> Dict[str, Any]:\n        \"\"\"Validate required fields.\"\"\"\n        # If connection_pool is provided, skip validation of individual parameters\n        if values.get(\"connection_pool\") is not None:\n            return values\n\n        required_fields = [\"host\", \"user\", \"database\"]\n        missing_fields = [field for field in required_fields if not values.get(field)]\n\n        if missing_fields:\n            raise ValueError(","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0/configs/vector_stores/azure_mysql.py#L38-L74","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Set use_azure_credential=True in the config to use Azure managed identity (DefaultAzureCredential) instead of a password","Provide the 'password' field directly in the vector store config dict","Pass a pre-built 'connection_pool' object (e.g. mysql.connector.pooling.MySQLConnectionPool), which skips all auth validation","Verify the config dict keys actually reach the validator (typos like 'passwd' or 'pass' silently drop the password)"],"exampleFix":"// before\nconfig = {\n    \"vector_store\": {\n        \"provider\": \"azure_mysql\",\n        \"config\": {\"host\": \"x.mysql.database.azure.com\", \"user\": \"u\", \"database\": \"db\"}\n    }\n}\n\n# after\nconfig = {\n    \"vector_store\": {\n        \"provider\": \"azure_mysql\",\n        \"config\": {\n            \"host\": \"x.mysql.database.azure.com\",\n            \"user\": \"u\",\n            \"database\": \"db\",\n            \"use_azure_credential\": True\n        }\n    }\n}","handlingStrategy":"validation","validationCode":"def validate_azure_mysql_auth(cfg: dict) -> None:\n    if cfg.get(\"connection_pool\") is not None:\n        return\n    if not cfg.get(\"use_azure_credential\", False) and not cfg.get(\"password\"):\n        raise RuntimeError(\"azure_mysql config needs 'password' or use_azure_credential=True\")","typeGuard":"def has_azure_mysql_auth(cfg: dict) -> bool:\n    return cfg.get(\"connection_pool\") is not None or bool(cfg.get(\"use_azure_credential\") or cfg.get(\"password\"))","tryCatchPattern":"from pydantic import ValidationError\ntry:\n    AzureMySQLConfig(**cfg)\nexcept ValidationError as e:\n    if \"use_azure_credential\" in str(e):\n        # resolve credentials / switch to managed identity, then retry construction\n        ...","preventionTips":["Centralize credential resolution so password or use_azure_credential is always set explicitly","Assert auth keys are present in a startup config check before Memory.from_config","Never rely on env vars the model does not document as reading"],"tags":["pydantic","configuration","vector-store","azure","mysql","authentication"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}