fix(storage): skip corrupt pages in list_pages to prevent KB-wide crashes#360
fix(storage): skip corrupt pages in list_pages to prevent KB-wide crashes#360RealDiligent wants to merge 1 commit into
Conversation
list_pages() lacked the _load_or_skip resilience applied to other list_* paths, so one bad pages/*.md file crashed status, search, lint, and MCP tools. Skip unreadable pages with a warning instead. Co-authored-by: Cursor <cursoragent@cursor.com>
📝 WalkthroughWalkthroughAdds a helper function ChangesResilient Page Listing
Estimated code review effort: 1 (Trivial) | ~5 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Is it really crashes? Attach the proof plz |
|
With v2.0.0, we'll be moving to a database-backed approach (e.g., SQLite) instead of Markdown files. That said, I'm still curious—under what circumstances could claims or pages become corrupted in the current or future setup? Are there specific failure modes we should be proactively guarding against (e.g., concurrent writes, partial saves, file system errors, or migration mishaps)? |
Summary
Root cause:
list_pages()was the only bulklist_*path that did not use the_load_or_skipresilience pattern. A single corrupt or hand-editedpages/*.mdfile (missing frontmatter, bad YAML, mojibake) raised an unhandled exception and crashedvouch status,vouch lint,kb.search(substring/hybrid fallback), MCPkb.list_pages, and other core paths - whilelist_claims(),list_proposals(), etc. already skipped bad files with a warning.Fix: Add
_load_page_or_skip()mirroring_load_or_skipand use it inlist_pages(). One regression test added alongside the existing claim test.Impact: One bad page no longer takes down the entire KB listing surface; operators get a logged warning and the rest of the vault keeps working.
Risk / tradeoffs
get_page(id)still raises for a targeted read - intentional, matchesget_claimsemantics.Test plan
test_list_pages_skips_unreadable_file(new)test_list_claims_skips_unreadable_fileSummary by CodeRabbit