{"record":{"id":"c402ba05df48aa9c","repo":"mem0ai/mem0","slug":"invalid-label-name-r","errorCode":null,"errorMessage":"Invalid {label}: {name!r}","messagePattern":"Invalid (.+?): (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mem0/vector_stores/databricks.py","lineNumber":47,"sourceCode":"\nlogger = logging.getLogger(__name__)\n\n\nclass MemoryResult(BaseModel):\n    id: Optional[str] = None\n    score: Optional[float] = None\n    payload: Optional[dict] = None\n\n\nexcluded_keys = {\"user_id\", \"agent_id\", \"run_id\", \"hash\", \"data\", \"created_at\", \"updated_at\"}\n\n# Pattern for valid SQL identifiers to prevent column name / table name injection\n_VALID_SQL_IDENTIFIER = re.compile(r\"^[A-Za-z_][A-Za-z0-9_]*$\")\n\n\ndef _validate_identifier(name: str, label: str = \"identifier\") -> str:\n    if not isinstance(name, str) or not _VALID_SQL_IDENTIFIER.match(name):\n        raise ValueError(f\"Invalid {label}: {name!r}\")\n    return name\n\n\nclass Databricks(VectorStoreBase):\n    def __init__(\n        self,\n        workspace_url: str,\n        access_token: Optional[str] = None,\n        client_id: Optional[str] = None,\n        client_secret: Optional[str] = None,\n        azure_client_id: Optional[str] = None,\n        azure_client_secret: Optional[str] = None,\n        endpoint_name: str = None,\n        catalog: str = None,\n        schema: str = None,\n        table_name: str = None,\n        collection_name: str = \"mem0\",\n        index_type: str = \"DELTA_SYNC\",","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0/vector_stores/databricks.py#L29-L65","documentation":"ValueError from _validate_identifier in databricks.py, applied to Databricks catalog/schema/table/index names before they are interpolated into SQL and SDK calls. The regex ^[A-Za-z_][A-Za-z0-9_]*$ requires a letter/underscore start and identifier-safe characters only; non-strings (None, int) are also rejected because of the isinstance check.","triggerScenarios":"Constructing the Databricks store with fully_qualified_index_name/table name parts containing hyphens, dots outside the expected splitting, quotes, or None (e.g. missing catalog env var). The validator runs on each identifier component during __init__ before any workspace call.","commonSituations":"Workspace/table names copied from the Databricks UI that contain hyphens; environment variables for catalog/schema not set (yielding None); names built by concatenating user input with separators like '-'.","solutions":["Use identifier-safe names: letters, digits, underscores, starting with a letter or underscore.","Ensure all name components are set (not None) and pass them as strings; check env vars before construction.","Sanitize dynamic fragments: re.sub(r'[^A-Za-z0-9_]', '_', part)."],"exampleFix":"# before\nDatabricks(workspace_url=..., catalog=None, ...)  # or table \"my-table\" -> ValueError\n\n# after\nDatabricks(workspace_url=..., catalog=\"main\", table_name=\"mem0_memories\", ...)","handlingStrategy":"validation","validationCode":"import re\n_SQL_IDENT = re.compile(r\"^[A-Za-z_][A-Za-z0-9_]*$\")\n\ndef databricks_name(label: str, value) -> str:\n    if not isinstance(value, str) or not _SQL_IDENT.match(value):\n        raise ValueError(f\"{label} must be a SQL identifier, got {value!r}\")\n    return value\n\ncatalog = databricks_name(\"catalog\", os.environ[\"DBX_CATALOG\"])\ntable = databricks_name(\"table_name\", os.environ.get(\"DBX_TABLE\", \"mem0_memories\"))","typeGuard":"def is_sql_identifier(name) -> bool:\n    import re\n    return isinstance(name, str) and bool(re.match(r\"^[A-Za-z_][A-Za-z0-9_]*$\", name))","tryCatchPattern":null,"preventionTips":["Check required name env vars are non-empty strings before constructing the store.","Generate names with underscores only: catalog_schema_table style.","Sanitize dynamic fragments and re-validate against the identifier regex."],"tags":["databricks","validation","identifier","injection-guard"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}