{"record":{"id":"716e0ccb76778732","repo":"MemPalace/mempalace","slug":"palace-must-be-a-palaceref-instance","errorCode":null,"errorMessage":"palace= must be a PalaceRef instance","messagePattern":"palace= must be a PalaceRef instance","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"mempalace/backends/qdrant.py","lineNumber":1384,"sourceCode":"            raise CollectionNotInitializedError(collection_name)\n        collection = QdrantCollection(\n            backend=self,\n            client=client,\n            config=config,\n            palace=palace,\n            collection_name=collection_name,\n            remote_collection=remote_collection,\n        )\n        with self._lock:\n            self._collections_by_palace.setdefault(palace.id, []).append(collection)\n        return collection\n\n    @staticmethod\n    def _normalize_args(args, kwargs):\n        if \"palace\" in kwargs:\n            palace = kwargs.pop(\"palace\")\n            if not isinstance(palace, PalaceRef):\n                raise TypeError(\"palace= must be a PalaceRef instance\")\n            collection_name = kwargs.pop(\"collection_name\")\n            create = bool(kwargs.pop(\"create\", False))\n            options = kwargs.pop(\"options\", None)\n            if args or kwargs:\n                raise TypeError(\"unexpected arguments to get_collection\")\n            return palace, collection_name, create, options\n        if args:\n            palace_path = args[0]\n            rest = list(args[1:])\n            collection_name = kwargs.pop(\"collection_name\", None) or (rest.pop(0) if rest else None)\n            if collection_name is None:\n                raise TypeError(\"collection_name is required\")\n            create = kwargs.pop(\"create\", False)\n            if rest:\n                create = rest.pop(0)\n            options = kwargs.pop(\"options\", None)\n            if rest or kwargs:\n                raise TypeError(\"unexpected arguments to get_collection\")","sourceCodeStart":1366,"sourceCodeEnd":1402,"githubUrl":"https://github.com/MemPalace/mempalace/blob/06cb6987f02610784fefbad4b2bd5d026d164ba6/mempalace/backends/qdrant.py#L1366-L1402","documentation":"A TypeError from get_collection's argument normalizer: palace= was passed but the value is not a PalaceRef instance. The qdrant backend requires a real PalaceRef (with id and local_path) when using the keyword form; strings are only accepted via the positional palace_path form.","triggerScenarios":"get_collection(palace=\"/path/to/palace\", collection_name=\"x\") — passing a path string to palace= instead of a PalaceRef; or passing a dict/Mock/other object in tests.","commonSituations":"Porting call sites from a path-based API to the PalaceRef API; test doubles that substitute plain objects for PalaceRef; passing a dataclass that quacks like PalaceRef but isn't.","solutions":["Wrap the value: PalaceRef(id=path, local_path=path) and pass palace=PalaceRef(...)","Or use the positional form: get_collection(\"/path/to/palace\", \"collection\")","In tests, construct real PalaceRef instances instead of stand-ins"],"exampleFix":"# before\nbackend.get_collection(palace=\"/data/palace\", collection_name=\"drawers\")\n# after\nref = PalaceRef(id=\"/data/palace\", local_path=\"/data/palace\")\nbackend.get_collection(palace=ref, collection_name=\"drawers\")","handlingStrategy":"type-guard","validationCode":"if not isinstance(palace, PalaceRef):\n    palace = PalaceRef(id=str(palace), local_path=str(palace))","typeGuard":"from mempalace.backends.base import PalaceRef\n\ndef is_palace_ref(v) -> bool:\n    \"\"\"Narrow v to a PalaceRef suitable for palace=.\"\"\"\n    return isinstance(v, PalaceRef) and v.local_path is not None","tryCatchPattern":null,"preventionTips":["Type-annotate call sites with PalaceRef so mypy catches misuse","Build PalaceRef in one place instead of passing raw paths"],"tags":["qdrant","api-misuse","typeerror","palaceref"],"backgroundTag":null,"analyzedSha":"06cb6987f02610784fefbad4b2bd5d026d164ba6","analyzedAt":"2026-08-15T03:03:36.213Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}