{"record":{"id":"476a3efcf0d51adc","repo":"microsoft/semantic-kernel","slug":"path-of-persist-directory-is-not-set","errorCode":null,"errorMessage":"Path of persist directory is not set","messagePattern":"Path of persist directory is not set","errorType":"exception","errorClass":"ServiceInitializationError","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/connectors/memory_stores/usearch/usearch_memory_store.py","lineNumber":163,"sourceCode":"        if self._persist_directory:\n            self._collections = self._read_collections_from_dir()\n\n    def _get_collection_path(self, collection_name: str, *, file_type: _CollectionFileType) -> Path:\n        \"\"\"Get the path for the given collection name and file type.\n\n        Args:\n            collection_name (str): Name of the collection.\n            file_type (_CollectionFileType): The file type.\n\n        Returns:\n            Path: Path to the collection file.\n\n        Raises:\n            ValueError: If persist directory path is not set.\n        \"\"\"\n        collection_name = collection_name.lower()\n        if self._persist_directory is None:\n            raise ServiceInitializationError(\"Path of persist directory is not set\")\n\n        return self._persist_directory / (collection_name + _collection_file_extensions[file_type])\n\n    async def create_collection(\n        self,\n        collection_name: str,\n        ndim: int = 0,\n        metric: str | MetricKind | CompiledMetric = MetricKind.IP,\n        dtype: str | ScalarKind | None = None,\n        connectivity: int | None = None,\n        expansion_add: int | None = None,\n        expansion_search: int | None = None,\n        view: bool = False,\n    ) -> None:\n        \"\"\"Create a new collection.\n\n        Args:\n            collection_name (str): Name of the collection. Case-insensitive.","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/memory_stores/usearch/usearch_memory_store.py#L145-L181","documentation":"Raised by USearchMemoryStore._get_collection_path (ServiceInitializationError) when it needs to compute a collection file path but `self._persist_directory` is None. This is a defensive guard; in normal flow create_collection only calls _get_collection_path when _persist_directory is already truthy, so this is most often hit by direct calls, subclass overrides, or an in-memory store being used where persistence is expected.","triggerScenarios":"Constructing `USearchMemoryStore()` with no `persist_directory`, then a code path that resolves a collection file path (directly or via a subclass/extension). Also reachable if persist_directory was set to a value that becomes falsy.","commonSituations":"Intended an in-memory store but later code (or a framework integration) expects on-disk persistence; copied code that assumes a persist_directory; misconfigured deployment where the directory env var is unset.","solutions":["Pass a persist_directory to the constructor: `USearchMemoryStore(persist_directory='/data/usearch')`.","Ensure the directory path exists and is writable before constructing the store.","If in-memory-only is intended, avoid code paths that require file paths (create_collection still works without persistence)."],"exampleFix":"// before\nstore = USearchMemoryStore()\n// after\nstore = USearchMemoryStore(persist_directory='/data/usearch')","handlingStrategy":"validation","validationCode":"from pathlib import Path\npersist_dir = Path('/data/usearch')\nif not persist_dir.exists():\n    persist_dir.mkdir(parents=True)\nstore = USearchMemoryStore(persist_directory=persist_dir)  # in-memory: omit and avoid file-path calls","typeGuard":null,"tryCatchPattern":"from semantic_kernel.exceptions import ServiceInitializationError\ntry:\n    store = USearchMemoryStore(persist_directory=maybe_dir)\nexcept ServiceInitializationError:\n    store = USearchMemoryStore()  # fall back to in-memory","preventionTips":["Always pass an existing, writable persist_directory if you need on-disk persistence.","Decide in-memory vs persisted up front and keep code paths consistent.","Validate the directory exists before constructing the store."],"tags":["usearch","memory-store","initialization","persistence","config"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}