fix(graph): normalize Windows backslash paths to forward slashes#61
Conversation
On Windows, path.relative() and path.join() return backslash separators. Graph node keys were stored with native separators, but query inputs use forward slashes, causing silent lookup failures on Windows. Add toForwardSlash() utility and apply it at build time (file walker, resolution functions) and query time (getFileDependencies, getSymbolContext, listSymbols) for defense-in-depth. No-op on macOS/Linux where path.relative() already returns forward slashes. Existing Windows symbol graph caches require one rebuild. Fixes #60
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds a toForwardSlash helper and applies forward-slash normalization across file collection, dependency lookups, symbol/cache access, and multi-language module resolution so graph keys and queries match regardless of OS path separators. ChangesWindows Path Separator Normalization
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/services/graph-analysis.ts`:
- Around line 16-17: The lookup currently normalizes the input path (normalized
= toForwardSlash(relativePath)) but compares it to the raw stored key
(n.relativePath), causing failures when graph nodes still have backslashes;
update the find predicate in graph.nodes.find to normalize the stored key as
well (e.g., use toForwardSlash(n.relativePath) === normalized) so both sides are
compared in forward-slash form, ensuring compatibility with legacy
Windows-cached nodes and preserving use of the existing toForwardSlash helper.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 73c32277-8eca-4392-8652-1393a541da69
📒 Files selected for processing (7)
src/constants.tssrc/services/code-graph.tssrc/services/graph-analysis.tssrc/services/graph-impact.tssrc/services/graph-resolution.tstests/unit/constants.test.tstests/unit/graph-analysis.test.ts
… compat Address CodeRabbit review: also normalize stored graph node keys when comparing, not just the query input. Handles pre-fix Windows caches where node keys still contain backslashes until the graph is rebuilt.
Summary
Fix silent graph query failures on Windows caused by path separator mismatch. On Windows,
path.relative()andpath.join()return backslash separators (src\index.ts), but query inputs use forward slashes (src/index.ts). Exact string comparison fails silently, returning empty results.Changes
toForwardSlash()utility tosrc/constants.tsfor centralized path normalizationcode-graph.tsso all graph node keys use forward slashes at build timegraph-resolution.ts(JVM suffix map, Rust paths, relative path resolution, fileSet lookups)graph-analysis.ts(getFileDependencies) andgraph-impact.ts(getSymbolContext,listSymbols)toForwardSlash()and backslash-path normalization ingetFileDependenciesType of change
Testing
npm run test:unit)npm run test:integration)npx tsc --noEmit)Checklist
Related issues
Fixes #60
Notes
path.relative()already returns forward slashescodebase_indexrebuild (UUID hashes change due to forward-slash keys)Summary by CodeRabbit