fix(graph-vfs): decode graph VFS paths safely so a malformed % never throws - #323
fix(graph-vfs): decode graph VFS paths safely so a malformed % never throws#323Diwak4r wants to merge 1 commit into
Conversation
…throws handleGraphVfs documents that it "never throws" and its VFS caller (resolveGraph) has no try/catch, but parsePath ran the remainder through decodeURIComponent, which raises URIError on a lone/short % escape (e.g. a `find/100%` pattern). Wrap the decode in a safeDecode helper that falls back to the raw string, honoring the never-throws contract.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthrough
ChangesGraph path safety
Estimated code review effort: 1 (Trivial) | ~5 minutes Suggested reviewers: Poem
🚥 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 |
Problem
handleGraphVfs(src/daemon/runtime/codebase/query.ts) documents that an unknown/odd path "returns a short usage listing (never throws)", and its VFS callerresolveGraph(src/daemon-client/vfs/read.ts) wraps it in no try/catch — its own docblock repeats "The renderer itself never throws".But
parsePathruns the path remainder throughdecodeURIComponent, which raisesURIError: URI malformedon a lone or short%escape. So a perfectly ordinary caller-supplied VFS path likegraph/find/100%(orgraph/show/a%zz,graph/neighborhood/src/x%.ts) throws out ofhandleGraphVfsinstead of rendering — breaking the documented contract and propagating out of an un-guarded caller.Fix
Route the remainder through a small
safeDecodehelper that returns the raw string whendecodeURIComponentthrows, so an undecodable remainder is passed through verbatim rather than blowing up the whole render. One-line call-site change plus the helper.How verified
tests/daemon/runtime/codebase/query.test.tscoveringfind/100%,show/a%zz, andneighborhood/src/x%.ts.npx vitest run tests/daemon/runtime/codebase/query.test.ts→ 26 passed.useIterableCallbackReturnwarning in this file is unrelated and present onmain).Summary by CodeRabbit
Bug Fixes
Tests