{"record":{"id":"fed1f9116afdc0c3","repo":"mem0ai/mem0","slug":"either-access-token-or-both-client-id-client-secre","errorCode":null,"errorMessage":"Either access_token or both client_id/client_secret or azure_client_id/azure_client_secret must be provided","messagePattern":"Either access_token or both client_id/client_secret or azure_client_id/azure_client_secret must be provided","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mem0/configs/vector_stores/databricks.py","lineNumber":55,"sourceCode":"        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_validator(mode=\"after\")\n    def validate_authentication(self):\n        \"\"\"Validate that either access_token or service principal credentials are provided.\"\"\"\n        has_token = self.access_token is not None\n        has_service_principal = (self.client_id is not None and self.client_secret is not None) or (\n            self.azure_client_id is not None and self.azure_client_secret is not None\n        )\n\n        if not has_token and not has_service_principal:\n            raise ValueError(\n                \"Either access_token or both client_id/client_secret or azure_client_id/azure_client_secret must be provided\"\n            )\n\n        return self\n\n    model_config = ConfigDict(arbitrary_types_allowed=True)\n","sourceCodeStart":37,"sourceCodeEnd":62,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0/configs/vector_stores/databricks.py#L37-L62","documentation":"Raised by DatabricksConfig.validate_authentication (mode='after', so it runs after field coercion) when no usable credential is present. Accepted: an access_token, or client_id+client_secret pair, or azure_client_id+azure_client_secret pair. With none of these, the config cannot authenticate to Databricks.","triggerScenarios":"Creating DatabricksConfig with host/warehouse fields but no credentials at all; providing client_id without client_secret (partial pair counts as no service principal); providing only Azure SP id without its secret. Because the validator is mode='after', None defaults survive to this check and fail here.","commonSituations":"Expecting Databricks CLI profile or DATABRICKS_TOKEN env var pickup (neither is read); token stored in a secret manager that returned None; SP rotation leaving one half of the pair unset in config.","solutions":["Set 'access_token' to a Databricks personal access token or PAT-equivalent","Or set both 'client_id' and 'client_secret' for a Databricks service principal (OAuth M2M)","Or set both 'azure_client_id' and 'azure_client_secret' for an Azure service principal","Assert credentials resolve from your secret store before building the config; env vars are not read automatically"],"exampleFix":"# before\nDatabricksConfig(host=\"https://adb-...\", warehouse_name=\"wh\")\n\n# after\nDatabricksConfig(host=\"https://adb-...\", warehouse_name=\"wh\", access_token=os.environ[\"DATABRICKS_TOKEN\"])","handlingStrategy":"validation","validationCode":"def validate_databricks_auth(cfg: dict) -> None:\n    token = cfg.get(\"access_token\") is not None\n    sp = (cfg.get(\"client_id\") and cfg.get(\"client_secret\")) or (\n        cfg.get(\"azure_client_id\") and cfg.get(\"azure_client_secret\")\n    )\n    if not token and not sp:\n        raise RuntimeError(\"Databricks config needs access_token or a full SP credential pair\")","typeGuard":"def databricks_auth_ok(cfg: dict) -> bool:\n    return cfg.get(\"access_token\") is not None or bool(\n        (cfg.get(\"client_id\") and cfg.get(\"client_secret\"))\n        or (cfg.get(\"azure_client_id\") and cfg.get(\"azure_client_secret\"))\n    )","tryCatchPattern":"from pydantic import ValidationError\ntry:\n    DatabricksConfig(**cfg)\nexcept ValidationError as e:\n    if \"access_token\" in str(e) and \"client_id\" in str(e):\n        # fetch token/SP pair from secret store, then retry\n        ...","preventionTips":["Explicitly pass tokens; Databricks env vars/profiles are not auto-read","Fetch SP pairs as a unit and assert both halves are non-None","Fail fast at startup if no credential source resolves"],"tags":["pydantic","configuration","vector-store","databricks","authentication"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}