{"record":{"id":"0715701c096a6b8f","repo":"MemPalace/mempalace","slug":"pgvector-backend-requires-a-local-palace-path-to-a","errorCode":null,"errorMessage":"pgvector backend requires a local palace path to anchor mismatch protection; pure-remote palaces (local_path=None) are not supported yet","messagePattern":"pgvector backend requires a local palace path to anchor mismatch protection; pure-remote palaces \\(local_path=None\\) are not supported yet","errorType":"exception","errorClass":"BackendError","httpStatus":null,"severity":"error","filePath":"mempalace/backends/pgvector.py","lineNumber":1515,"sourceCode":"    def get_collection(self, *args, **kwargs) -> PgVectorCollection:\n        palace, collection_name, create, options = self._normalize_args(args, kwargs)\n        config = _PgVectorConfig.from_options(options)\n        if palace.namespace and palace.namespace != config.namespace:\n            config = _PgVectorConfig(dsn=config.dsn, namespace=palace.namespace)\n        client = self._client(config)\n        if palace.local_path:\n            marker_path = self._marker_path(palace.local_path)\n            if os.path.isfile(marker_path):\n                self._validate_marker_target(palace, config)\n            elif not create:\n                raise PalaceNotFoundError(marker_path)\n        else:\n            # The local marker is this backend's only mismatch-protection\n            # anchor. With no local_path (pure-remote / hosted mode) we can\n            # neither write nor validate it, so opening would silently drop\n            # protection against DSN/namespace drift. Refuse loudly. A remote\n            # marker store for pure-remote palaces is tracked as a follow-up.\n            raise BackendError(\n                \"pgvector backend requires a local palace path to anchor mismatch \"\n                \"protection; pure-remote palaces (local_path=None) are not \"\n                \"supported yet\"\n            )\n        table = self._table_name(palace=palace, collection_name=collection_name, config=config)\n        if not create and not client.table_exists(table):\n            raise CollectionNotInitializedError(collection_name)\n        collection = PgVectorCollection(\n            backend=self,\n            client=client,\n            config=config,\n            palace=palace,\n            collection_name=collection_name,\n            table=table,\n        )\n        with self._lock:\n            self._collections_by_palace.setdefault(palace.id, []).append(collection)\n        return collection","sourceCodeStart":1497,"sourceCodeEnd":1533,"githubUrl":"https://github.com/MemPalace/mempalace/blob/06cb6987f02610784fefbad4b2bd5d026d164ba6/mempalace/backends/pgvector.py#L1497-L1533","documentation":"The pgvector backend's only mismatch protection is the local marker file inside the palace directory. With palace.local_path=None (pure-remote/hosted mode) it can neither write nor validate the marker, so opening would silently drop protection against DSN/namespace drift — therefore it refuses loudly with BackendError. Remote marker storage for pure-remote palaces is tracked as follow-up work.","triggerScenarios":"Constructing a PalaceRef with local_path=None and requesting the pgvector backend: backend.get_collection(PalaceRef(name=\"x\", local_path=None), \"notes\").","commonSituations":"Server/hosted deployments that keep palace state only in Postgres; refactoring from a local path to a remote-only PalaceRef; early experiments with headless palaces.","solutions":["Provide a local palace directory (local_path set to a writable path) so the marker can anchor the palace.","Until remote markers ship, keep a small local state dir per palace even in server deployments.","Track the upstream remote-marker-store feature if pure-remote mode is required."],"exampleFix":"# before\npalace = PalaceRef(name=\"notes\", local_path=None)\ncol = pgvector_backend.get_collection(palace, \"notes\")\n\n# after\npalace = PalaceRef(name=\"notes\", local_path=\"/var/lib/mempalace/notes\")\ncol = pgvector_backend.get_collection(palace, \"notes\", create=True)","handlingStrategy":"validation","validationCode":"if palace.local_path is None:\n    palace = PalaceRef(name=palace.name, local_path=default_state_dir(palace.name))\ncol = backend.get_collection(palace, \"notes\", create=True)","typeGuard":"def supports_pgvector(palace) -> bool:\n    return palace.local_path is not None","tryCatchPattern":"try:\n    col = backend.get_collection(palace, \"notes\")\nexcept BackendError as e:\n    if \"local palace path\" in str(e):\n        raise RuntimeError(\"pgvector backend needs a local palace dir; set local_path\")","preventionTips":["Always provision a small local state directory per palace, even in server deployments.","Check palace.local_path before selecting the pgvector backend."],"tags":["pgvector","remote-mode","unsupported-operation","config"],"backgroundTag":null,"analyzedSha":"06cb6987f02610784fefbad4b2bd5d026d164ba6","analyzedAt":"2026-08-15T03:03:36.213Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}