Title: Bug: `get_module_summary` returns files=0/functions=0/lines=0 on Windows (path_matches only checks `/` separator) · Issue #5 · codegraph-ai/CodeGraph · GitHub
Open Graph Title: Bug: `get_module_summary` returns files=0/functions=0/lines=0 on Windows (path_matches only checks `/` separator) · Issue #5 · codegraph-ai/CodeGraph
X Title: Bug: `get_module_summary` returns files=0/functions=0/lines=0 on Windows (path_matches only checks `/` separator) · Issue #5 · codegraph-ai/CodeGraph
Description: Bug Report Summary get_module_summary returns files=0, functions=0, classes=0, lines=0 on Windows for any directory. external_deps incorrectly returns all workspace-wide external dependencies instead of module-scoped ones. Environment OS...
Open Graph Description: Bug Report Summary get_module_summary returns files=0, functions=0, classes=0, lines=0 on Windows for any directory. external_deps incorrectly returns all workspace-wide external dependencies inste...
X Description: Bug Report Summary get_module_summary returns files=0, functions=0, classes=0, lines=0 on Windows for any directory. external_deps incorrectly returns all workspace-wide external dependencies inste...
Opengraph URL: https://github.com/codegraph-ai/CodeGraph/issues/5
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Bug: `get_module_summary` returns files=0/functions=0/lines=0 on Windows (path_matches only checks `/` separator)","articleBody":"## Bug Report\n\n### Summary\n\n`get_module_summary` returns `files=0`, `functions=0`, `classes=0`, `lines=0` on Windows for any directory. `external_deps` incorrectly returns all workspace-wide external dependencies instead of module-scoped ones.\n\n### Environment\n- **OS**: Windows 10/11\n- **Package**: `@astudioplus/codegraph-mcp` 0.18.2–0.18.4\n- **Graph size**: 65,556 nodes, 2,615 CodeFiles\n\n### Root Cause\n\nFile: `crates/codegraph-server/src/domain/module_summary.rs`, function `path_matches()` (line ~217):\n\n```rust\nfn path_matches(path: \u0026str, prefix: \u0026str) -\u003e bool {\n if prefix.is_empty() { return true; }\n if path == prefix { return true; }\n path.starts_with(prefix) \u0026\u0026 path[prefix.len()..].starts_with('/') // \u003c-- BUG\n}\n```\n\nOn Windows, the graph stores paths with backslash separators (via `file_path.display().to_string()`):\n- `path` = `\"C:\\Users\\...\\agent\\prompt_builder.py\"`\n- `prefix` = `\"C:\\Users\\...\\agent\"`\n\n`path.starts_with(prefix)` is `true`, but `path[prefix.len()..]` starts with `\\` not `/`, so the function returns `false`. Every CodeFile/Function/Class node is skipped, resulting in all-zero counts.\n\nI verified this with a local Rust reproduction:\n\n```\npath_matches_original(\"C:\\Users\\...\\agent\\prompt_builder.py\", \"C:\\Users\\...\\agent\") =\u003e false\npath_matches_fixed(\"C:\\Users\\...\\agent\\prompt_builder.py\", \"C:\\Users\\...\\agent\") =\u003e true\n```\n\n### Proposed Fix\n\nNormalise both sides to forward slashes before comparing:\n\n```rust\n#[inline]\nfn path_matches(path: \u0026str, prefix: \u0026str) -\u003e bool {\n if prefix.is_empty() {\n return true;\n }\n let norm_path: String = path.replace('\\\\', \"/\");\n let norm_prefix: String = prefix.replace('\\\\', \"/\");\n if norm_path == norm_prefix {\n return true;\n }\n norm_path.starts_with(norm_prefix.as_str())\n \u0026\u0026 norm_path[norm_prefix.len()..].starts_with('/')\n}\n```\n\nWith corresponding Windows test cases:\n\n```rust\n#[test]\nfn test_path_matches_windows_backslash() {\n assert!(path_matches(\n \"C:\\\\Users\\\\me\\\\project\\\\src\\\\main.rs\",\n \"C:/Users/me/project/src\"\n ));\n}\n\n#[test]\nfn test_path_matches_windows_backslash_prefix() {\n assert!(path_matches(\n \"C:\\\\Users\\\\me\\\\project\\\\src\\\\main.rs\",\n \"C:\\\\Users\\\\me\\\\project\\\\src\"\n ));\n}\n\n#[test]\nfn test_path_matches_windows_no_partial_dir() {\n assert!(!path_matches(\n \"C:\\\\Users\\\\me\\\\project\\\\src_foo\\\\main.rs\",\n \"C:/Users/me/project/src\"\n ));\n}\n```\n\n### Additional Issue: `trim_end_matches('/')` doesn't trim `\\`\n\nLine 64: `let prefix = directory.trim_end_matches('/');`\n\nThis also needs to trim backslash on Windows. Suggested fix:\n\n```rust\nlet prefix = directory.trim_end_matches(|c| c == '/' || c == '\\\\');\n```\n\n### Steps to Reproduce\n\n1. Install codegraph-mcp on Windows\n2. Index a workspace\n3. Call `get_module_summary` with any valid directory path:\n ```\n get_module_summary(path=\"C:\\\\Users\\\\me\\\\project\\\\src\")\n ```\n4. Observe: `files=0`, `total_functions=0`, `total_classes=0`, `total_lines=0`\n\n### Expected Result\n\nNon-zero counts matching the actual files/functions/classes in that directory.\n\n### Workaround\n\nNone currently available — the bug is in the compiled Rust binary.\n","author":{"url":"https://github.com/MuBeiGe","@type":"Person","name":"MuBeiGe"},"datePublished":"2026-06-05T15:58:47.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/5/CodeGraph/issues/5"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:9331629d-2bb5-7032-531c-4a062e583bac |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 98B4:104714:8FB81C:CF45BD:6A4CE893 |
| html-safe-nonce | aec0c5ad95d8149c6907d8c6d7461787e4aca5e2c1f1576d62460b2396906836 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5OEI0OjEwNDcxNDo4RkI4MUM6Q0Y0NUJEOjZBNENFODkzIiwidmlzaXRvcl9pZCI6IjY4MDc3ODUxMjAyOTM3NzU1MDciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | ac3d5f2a7b850eb743398e6bc503f65f7486a9604c4cad14838c37b7ff991789 |
| hovercard-subject-tag | issue:4598264002 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/codegraph-ai/CodeGraph/5/issue_layout |
| twitter:image | https://opengraph.githubassets.com/321c3418d963ab407da058b4079e4e043a1ae183c0f43013f5cabf9dc818f8d5/codegraph-ai/CodeGraph/issues/5 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/321c3418d963ab407da058b4079e4e043a1ae183c0f43013f5cabf9dc818f8d5/codegraph-ai/CodeGraph/issues/5 |
| og:image:alt | Bug Report Summary get_module_summary returns files=0, functions=0, classes=0, lines=0 on Windows for any directory. external_deps incorrectly returns all workspace-wide external dependencies inste... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | MuBeiGe |
| hostname | github.com |
| expected-hostname | github.com |
| None | 299b43bca6e02ad35197ffeba30d2466846d5fb02ab96fbced5b5e6cec589fb8 |
| turbo-cache-control | no-preview |
| go-import | github.com/codegraph-ai/CodeGraph git https://github.com/codegraph-ai/CodeGraph.git |
| octolytics-dimension-user_id | 249074060 |
| octolytics-dimension-user_login | codegraph-ai |
| octolytics-dimension-repository_id | 1201596241 |
| octolytics-dimension-repository_nwo | codegraph-ai/CodeGraph |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1201596241 |
| octolytics-dimension-repository_network_root_nwo | codegraph-ai/CodeGraph |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | c5a57f04eeb310f57c73fd6d751d957e2ca27ed2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width