fix/mcp-taxonomy-pagination (#171) - #202
Conversation
fix/mcp-taxonomy-pagination
PR Review: fix/mcp-taxonomy-pagination (#171)Executive Summary
Affected Areas: Business Impact: Palaces with >10k drawers now return complete taxonomy data instead of silently truncated or empty results. This directly fixes incorrect Flow Changes: All 4 taxonomy tools now iterate metadata in 500-item pages via Ratings
PR Health
Medium Priority Issues(Should fix, not blocking) 🐛 #1:
|
- add partial flag to tool_status when metadata count diverges from col.count() - fix `if where` → `if where is not None` in _iter_metadatas - add TestTaxonomyPagination covering pagination for all 4 tools, partial flag, and tool_list_rooms with where filter Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Hey — I've taken a look and ran it through CLI. Thanks for the fix on the MCP taxonomy pagination bug! There are two open PRs addressing #171 and going with #307 because its title framing ("log instead of swallowing errors") is the correct fix shape — silent errors in MCP tools are user-hostile. Closing this one as superseded. Really appreciate the contribution. 💜 |
|
Reopening — this was closed too quickly and your work deserves proper review. Standing by for merge once we clear the current security baseline. Thank you for the contribution. |
|
#307 is the cleaner solution, closing this one |
## What does this PR do?
Fixes a silent data-loss bug (#171) in the four MCP taxonomy tools (
mempalace_status,mempalace_list_wings,mempalace_list_rooms,mempalace_get_taxonomy). On palaces with more than ~10k drawers, all four functions calledcol.get(limit=10000)in a single shot and wrapped the whole thing inexcept Exception: pass. Two things could go wrong:Noneformetadatason large collections, causing aTypeError: 'NoneType' is not iterablethat gets swallowed — result:{"wings": {}}on a 96k-drawer palace.The fix extracts a shared
_iter_metadatas(col, where=None)generator that pages through the collection in batches of 500 (the same pattern already used correctly inlayers.py), guards againstNonemetadatas at each page, and logs a warning instead of silently swallowing errors. All four taxonomy functions are updated to use it.## How to test
The three new tests in
TestTaxonomyPaginationmonkey-patch_TAXONOMY_BATCH = 2to force multi-page fetching on a small fixture, then assert all items are counted across pages. A third test confirms graceful handling when ChromaDB returnsNoneformetadatas.## Checklist
python -m pytest tests/ -v)ruff check .)