{"record":{"id":"1c3d10a60afd2138","repo":"zylon-ai/private-gpt","slug":"local-storage-provider-requires-local-root-path","errorCode":null,"errorMessage":"Local storage provider requires local_root_path","messagePattern":"Local storage provider requires local_root_path","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"private_gpt/components/storage/storage_component.py","lineNumber":39,"sourceCode":"        self._lock = threading.RLock()\n        self._storages: dict[str, ObjectStorage] = {}\n\n    def get_object_storage(\n        self,\n        provider: str,\n        local_root_path: str | None = None,\n        bucket_name: str | None = None,\n    ) -> ObjectStorage:\n        key = f\"{provider}:{local_root_path}:{bucket_name}\"\n        with self._lock:\n            storage = self._storages.get(key)\n            if storage is not None:\n                return storage\n\n            match provider:\n                case \"local\":\n                    if local_root_path is None:\n                        raise ValueError(\n                            \"Local storage provider requires local_root_path\"\n                        )\n\n                    storage = LocalObjectStorage(root_path=local_root_path)\n                case \"s3\":\n                    if bucket_name is None:\n                        raise ValueError(\"S3 storage provider requires bucket_name\")\n                    storage = S3ObjectStorage(\n                        s3_helper=self._injector.get(S3Helper),\n                        bucket_name=bucket_name,\n                    )\n                case _:\n                    raise ValueError(f\"Unsupported storage provider: {provider}\")\n\n            self._storages[key] = storage\n            return storage\n","sourceCodeStart":21,"sourceCodeEnd":56,"githubUrl":"https://github.com/zylon-ai/private-gpt/blob/4a030776a31a901ad80b1bf4d7faa2c1a367efbb/private_gpt/components/storage/storage_component.py#L21-L56","documentation":"Raised by StorageComponent when creating storage with provider=\"local\" but local_root_path=None. The factory method requires a root path to construct a LocalObjectStorage; both parameters default to None so the caller must supply the one matching the chosen provider. It is a configuration/validation error thrown before any filesystem access happens.","triggerScenarios":"Calling the storage factory method with provider=\"local\" and omitting local_root_path (it defaults to None). Typically happens when settings (e.g. storage.local_root_path) are missing from the YAML/env config and None is passed through.","commonSituations":"Fresh deployment with an incomplete settings.yaml; renaming of the settings key between versions; tests that construct the component without a full Settings object.","solutions":["Set the local root path in configuration (e.g. storage: local_root_path: /var/lib/private_gpt/local_storage) so the factory receives a non-None value","If calling the factory directly, pass local_root_path=\"/some/path\" as the second argument","Add a pydantic validator on Settings to fail fast at startup with a clearer message when provider is local and the path is missing"],"exampleFix":"# before\nstorage = storage_component.get_storage(provider=\"local\")\n# after\nstorage = storage_component.get_storage(\n    provider=\"local\",\n    local_root_path=settings.storage.local_root_path,\n)","handlingStrategy":"validation","validationCode":"from private_gpt.components.storage.storage_component import StorageComponent\n\ndef validate_local_storage(sc: StorageComponent, local_root_path: str | None) -> None:\n    if local_root_path is None:\n        raise ValueError(\"configure storage.local_root_path before provider=local\")\n    sc.get_storage(provider=\"local\", local_root_path=local_root_path)","typeGuard":"def is_local_storage_ready(provider: str, local_root_path: str | None) -> bool:\n    return provider != \"local\" or local_root_path is not None","tryCatchPattern":null,"preventionTips":["Add a pydantic model_validator on Settings asserting provider-specific fields are set","Fail fast at startup, not at first storage call"],"tags":["storage","configuration","validation","local-filesystem"],"backgroundTag":null,"analyzedSha":"4a030776a31a901ad80b1bf4d7faa2c1a367efbb","analyzedAt":"2026-08-15T03:51:26.951Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}