{"record":{"id":"05bdc94f8669760c","repo":"microsoft/semantic-kernel","slug":"persist-directory-is-not-set","errorCode":null,"errorMessage":"Persist directory is not set","messagePattern":"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":543,"sourceCode":"                    filtered_vectors,\n                )\n            )\n        ]\n\n    def _get_all_storage_files(self) -> dict[str, list[Path]]:\n        \"\"\"Return storage files for each collection in `self._persist_directory`.\n\n        Collection name is derived from file name and converted to lowercase. Files with extensions that\n        do not match storage extensions are discarded.\n\n        Raises:\n            ValueError: If persist directory is not set.\n\n        Returns:\n            Dict[str, List[Path]]: Dictionary of collection names mapped to their respective files.\n        \"\"\"\n        if self._persist_directory is None:\n            raise ServiceInitializationError(\"Persist directory is not set\")\n\n        storage_exts = _collection_file_extensions.values()\n        collection_storage_files: dict[str, list[Path]] = {}\n        for path in self._persist_directory.iterdir():\n            if path.is_file() and (path.suffix in storage_exts):\n                collection_name = path.stem.lower()\n                if collection_name in collection_storage_files:\n                    collection_storage_files[collection_name].append(path)\n                else:\n                    collection_storage_files[collection_name] = [path]\n        return collection_storage_files\n\n    def _dump_collections(self) -> None:\n        collection_storage_files = self._get_all_storage_files()\n        for file_path in itertools.chain.from_iterable(collection_storage_files.values()):\n            file_path.unlink()\n\n        for collection_name, ucollection in self._collections.items():","sourceCodeStart":525,"sourceCodeEnd":561,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/memory_stores/usearch/usearch_memory_store.py#L525-L561","documentation":"Raised by USearchMemoryStore._get_all_storage_files (ServiceInitializationError) when _persist_directory is None. This method enumerates on-disk collection files; without a directory there is nothing to scan. It is called during _read_collections_from_dir / re-resolution, so it effectively means 'persistence was never configured but on-disk collection discovery was attempted'.","triggerScenarios":"Constructing `USearchMemoryStore()` without persist_directory and then invoking any internal path that re-scans storage files (e.g. reloading collections). In normal construction, the directory scan is skipped when _persist_directory is falsy, so this is reached via later/direct calls.","commonSituations":"In-memory store used in a context that later tries to discover collections from disk; misconfigured deployment missing the directory env var; subclass or framework hook calling storage discovery.","solutions":["Pass a valid persist_directory to the constructor.","Ensure the directory exists and is readable.","Avoid code paths that require on-disk discovery for in-memory stores."],"exampleFix":"// before\nstore = USearchMemoryStore()\n// after\nstore = USearchMemoryStore(persist_directory='/data/usearch')","handlingStrategy":"validation","validationCode":"from pathlib import Path\nd = Path('/data/usearch')\nassert d.exists(), 'persist directory required for storage discovery'\nstore = USearchMemoryStore(persist_directory=d)","typeGuard":null,"tryCatchPattern":"from semantic_kernel.exceptions import ServiceInitializationError\ntry:\n    store = USearchMemoryStore(persist_directory=d)\nexcept ServiceInitializationError:\n    store = USearchMemoryStore()","preventionTips":["Always configure persist_directory when on-disk discovery is needed.","Verify the directory is readable before constructing the store.","Keep persistence configuration consistent across the process lifecycle."],"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"}