-
-
Notifications
You must be signed in to change notification settings - Fork 441
Description
Bug Description
cgc visualize Playground renders all nodes but 0 edges when using the KuzuDB backend, even though the graph database contains thousands of relationships (IMPORTS, CONTAINS, HAS_PARAMETER). The Playground is effectively unusable for KuzuDB users — you see disconnected dots instead of a connected graph.
Root Cause
viz/server.py's get_graph() function assumes Neo4j/FalkorDB node/relationship objects with .labels, .id, .start_node attributes. KuzuDB returns plain Python dicts with _id, _label, _src, _dst keys.
Since dicts don't have those object attributes:
- Node IDs fall through to
str(id(element))(Python memory addresses) — unstable and non-matching - Relationship source/target are always
None→ edges are silently dropped by theif source and targetguard
Steps to Reproduce
- Configure KuzuDB backend:
cgc config set DEFAULT_DATABASE kuzudb - Index a repository:
cgc index /path/to/repo - Verify edges exist via CLI:
cgc analyze callers ...or direct KuzuDB query confirms IMPORTS/CONTAINS edges - Launch Playground:
cgc visualize - Observe: nodes render correctly, but edge count is 0
Expected Behavior
Edges should be visible in the Playground, matching what exists in the KuzuDB graph.
Actual Behavior
- Before fix: 7,537 nodes, 0 edges
- After fix: 3,869 nodes, 2,798 edges (CONTAINS, IMPORTS, HAS_PARAMETER)
Environment
- CGC version: 0.3.1
- kuzu: 0.11.3
- OS: Windows 11
- Python: 3.12
Proposed Fix
Add isinstance(node, dict) / isinstance(rel, dict) checks in get_graph() to handle KuzuDB's dict-based results:
- New helper
_kuzu_id(id_dict)to convert{'table': N, 'offset': M}to stable"N:M"string keys - Node processing: read
_labelfrom dict, filter_-prefixed internal keys from properties - Relationship processing: read
_src/_dst/_labeldirectly from dict
All existing Neo4j/FalkorDB code paths remain unchanged — the dict checks are additive if/else branches.
I have a working fix ready and will submit a PR shortly.