Repository navigation
[Bug] KuzuDB 0.11.3 backend: systemic query incompatibilities break call-graph, deps, and resolution phase #769
Description
Summary
The KuzuDB backend in CGC 0.3.1 has three distinct query compatibility failures with KuzuDB 0.11.3 that collectively break call-graph edges, dependency analysis, and the resolution phase of indexing. These appear to be the root cause behind several existing open issues (#727, #756, #757, #683, #684).
Environment
- CGC: 0.3.1
- KuzuDB: 0.11.3 (kuzu Python package)
- Python: 3.13.5
- OS: Windows 11
- Config:
INDEX_SOURCE=false,INDEX_VARIABLES=false,DEFAULT_DATABASE=kuzudb
Three Distinct Failures
1. Resolution phase: "Casting between NODE and NODE is not implemented"
During the resolution phase (after parsing completes at 100%), every single call-graph edge insertion fails:
ERROR - Kuzu Query failed:
OPTIONAL MATCH (caller:Function {name: $caller_name, path: $caller_file_path})
... Error: Runtime exception: Casting between NODE and NODE is not implemented.
Impact: Zero call-graph edges are stored. The resolution phase burns CPU for ~45+ minutes on a 1312-file repo producing no useful output. analyze callers and analyze calls return empty or near-empty results.
2. Dependency queries: "Variable file is not in scope"
analyze deps (module dependencies) fails with a Binder exception:
MATCH (file:File)-[imp:IMPORTS]->(module:Module {name: $module_name})
WHERE 1=1 {repo_filter}
OPTIONAL MATCH (repo:Repository)-[:CONTAINS]->(file)
... Error: Binder exception: Variable file is not in scope.
The file variable from the first MATCH clause is not visible in the subsequent OPTIONAL MATCH in KuzuDB's query planner.
3. Fulltext index creation: Parser exception on CALL db.idx.fulltext.createNodeIndex
On every cgc command (list, find, etc.), two errors appear:
ERROR - Kuzu Query failed: CALL db.idx.fulltext.createNodeIndex('Function', 'name', 'source', 'docstring')
... Error: Parser exception: Invalid input <CALL db.>: expected rule oC_Statement
Impact: Full-text search (find content) is broken. Node lookup (find name) still works because it uses exact match, not fulltext.
What Works vs What's Broken
| Feature | Status | Notes |
|---|---|---|
find name (exact node lookup) |
✅ Works | Simple node query |
find pattern (substring) |
✅ Works | Simple node query |
analyze tree (inheritance) |
✅ Works | INHERITS edges stored during parse phase |
analyze callers (call graph) |
❌ Broken | "Casting NODE/NODE" kills edge creation |
analyze calls (callees) |
❌ Broken | Same casting error |
analyze chain (call chain) |
❌ Broken | Depends on call edges |
analyze deps (imports) |
❌ Broken | "Variable not in scope" |
find content (fulltext) |
❌ Broken | Fulltext index creation fails |
Reproduction
# 1. Install CGC with KuzuDB
pip install codegraphcontext kuzu
# 2. Configure
cgc config set DEFAULT_DATABASE kuzudb
cgc config set INDEX_SOURCE false
cgc config set INDEX_VARIABLES false
# 3. Index any Python repo with >50 files
cgc index /path/to/repo --force
# Observe: progress bar reaches 100%, then resolution phase spews
# "Casting between NODE and NODE" errors for 30-60+ minutes
# 4. Test queries
cgc analyze callers "any_function" # empty or near-empty
cgc analyze deps "any_module" # crashes with "Variable not in scope"
cgc find content "any_string" # fails silently (no fulltext index)Root Cause Hypothesis
CGC's Cypher queries were likely developed/tested against an older KuzuDB version (possibly 0.8.x-0.10.x). KuzuDB 0.11.x appears to have introduced:
- Stricter type casting rules for node variables across
OPTIONAL MATCHchains - Changes to variable scoping in multi-clause queries
- Different syntax for fulltext index creation (
CALL db.idx...vs whatever the new API is)
Suggested Fix
The database_kuzu.py translation layer needs to be updated for KuzuDB 0.11.x query semantics. The three failures are in different query patterns but share a common cause: the Neo4j-to-Kuzu query translator produces queries that 0.11.x rejects.
Additionally, the resolution phase should fail fast rather than retrying the same broken query pattern thousands of times. A single failed OPTIONAL MATCH pattern should disable that query type for the rest of the run, not repeat the error for every call in every file.
Workaround
For users who only need symbol lookup (find name, find pattern, analyze tree), CGC with KuzuDB still works. The parsing phase correctly stores nodes and inheritance edges. Call-graph and dependency features require either:
- Downgrading kuzu to a compatible version (untested — which version works?)
- Using Neo4j or FalkorDB backend instead
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
github-actions commentedon Mar 29, 2026
Hi! 👋 Join our CodeGraphContext Discord channel to collaborate: https://discord.gg/dR4QY32uYQ
Shashankss1205 commentedon Mar 29, 2026
Hey @tucaman I am working on the exact same bug, there's a bug in kuzudb indexing logic and hence I need some time figuring this out
Shashankss1205 commentedon Mar 29, 2026
Hey @tucaman can you check if the kuzudb indexing works now??
tucaman commentedon Mar 29, 2026
Did you make any progress already? Or do you want me to create a fix?
Shashankss1205 commentedon Mar 29, 2026
https://pypi.org/project/codegraphcontext/0.3.5/
tucaman commentedon Mar 29, 2026
Will test now
Shashankss1205 commentedon Mar 29, 2026
Fixed it in the latest PR, need some testing
tucaman commentedon Mar 29, 2026
@Shashankss1205 Thanks for the quick response!
We upgraded from 0.3.1 → 0.3.4 (via
uv pip install --upgrade codegraphcontext) and re-tested. Same three failures persist on 0.3.4:CALL db.idx.fulltext.createNodeIndexstill fails with parser exception on every commandanalyze depsstill crashes with "Variable file is not in scope"analyze callers "transform"returns only 1 caller (should be dozens) — resolution phase still logs "Casting between NODE and NODE" for every edgeWe also tried installing 0.3.5 but it can't resolve — it depends on
inquirerpy>=0.3.5which doesn't exist on PyPI yet:Happy to test a fix if you point us to a branch or pre-release. Our setup:
INDEX_SOURCE=false,INDEX_VARIABLES=falseShashankss1205 commentedon Mar 29, 2026
Hey, please test 0.3.5 and beyond versions.
tucaman commentedon Mar 29, 2026
Hi, would love to, but cannot sync:
fixing #769
Shashankss1205 commentedon Mar 29, 2026
Umm, Another version-
https://pypi.org/project/codegraphcontext/0.3.7/
Let me know if this works, or I will have to recheck each dependency again with 100% perfect way out
tucaman commentedon Apr 6, 2026
CGC 0.3.9 Upgrade Report — adAPPter_uv (Windows 11)
Environment
Indexing Results
PR #796 is a massive improvement. The UNWIND batching fix completely resolves the CALLS edge creation failure. Breakdown: fn→fn=34,178, fn→cls=905, cls→fn=6,006, file→fn=1,182, file→cls=27.
Feature Test Results
find nameanalyze callerstransform— works!analyze treeanalyze depsBinder exception: Variable file is not in scope(#757)find contentCALL db.idx.fulltext.createNodeIndexparser error)Summary
3/5 features now working (up from 2/5 on 0.3.7). The CALLS engine rewrite is the key fix — call graph analysis is now functional and fast.
Still broken:
analyze deps— [Bug] module_deps query fails with KeyError 'imported_by_files' #757 scoping bug in OPTIONAL MATCH queryfind content— KuzuDB 0.11.x fulltext index limitationMinor issues:
.ruff_cacheand.pentagondirectories generate thousands of "No parser found" warnings — should be added to IGNORE_DIRS or.cgcignoreShashankss1205 commentedon Apr 30, 2026
Hey @sonxy-cn thanks for bringing this to notice. I will try to shift from kuzudb to ladybug db, because of better maintainability.
fixing CodeGraphContext#769