MemPalace/mempalace · error · TypeError
palace= must be a PalaceRef instance
Error message
palace= must be a PalaceRef instance
What it means
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.
Source
Thrown at mempalace/backends/qdrant.py:1384
raise CollectionNotInitializedError(collection_name)
collection = QdrantCollection(
backend=self,
client=client,
config=config,
palace=palace,
collection_name=collection_name,
remote_collection=remote_collection,
)
with self._lock:
self._collections_by_palace.setdefault(palace.id, []).append(collection)
return collection
@staticmethod
def _normalize_args(args, kwargs):
if "palace" in kwargs:
palace = kwargs.pop("palace")
if not isinstance(palace, PalaceRef):
raise TypeError("palace= must be a PalaceRef instance")
collection_name = kwargs.pop("collection_name")
create = bool(kwargs.pop("create", False))
options = kwargs.pop("options", None)
if args or kwargs:
raise TypeError("unexpected arguments to get_collection")
return palace, collection_name, create, options
if args:
palace_path = args[0]
rest = list(args[1:])
collection_name = kwargs.pop("collection_name", None) or (rest.pop(0) if rest else None)
if collection_name is None:
raise TypeError("collection_name is required")
create = kwargs.pop("create", False)
if rest:
create = rest.pop(0)
options = kwargs.pop("options", None)
if rest or kwargs:
raise TypeError("unexpected arguments to get_collection")View on GitHub (pinned to 06cb6987f0)
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
Example fix
# before backend.get_collection(palace="/data/palace", collection_name="drawers") # after ref = PalaceRef(id="/data/palace", local_path="/data/palace") backend.get_collection(palace=ref, collection_name="drawers")
Defensive patterns
Strategy: type-guard
Validate before calling
if not isinstance(palace, PalaceRef):
palace = PalaceRef(id=str(palace), local_path=str(palace)) Type guard
from mempalace.backends.base import PalaceRef
def is_palace_ref(v) -> bool:
"""Narrow v to a PalaceRef suitable for palace=."""
return isinstance(v, PalaceRef) and v.local_path is not None Prevention
- Type-annotate call sites with PalaceRef so mypy catches misuse
- Build PalaceRef in one place instead of passing raw paths
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- unexpected arguments to get_collection
- collection_name is required
- get_collection requires palace= or a positional palace_path
- qdrant requires explicit embeddings
- add ids must be unique
AI-assisted analysis of MemPalace/mempalace@06cb6987f0 (2026-08-15).
Data as JSON: /api/errors/716e0ccb76778732.
Report an issue: GitHub.