E3FE fix: Playground UI shows no edges when using KuzuDB backend · Issue #722 · CodeGraphContext/CodeGraphContext · GitHub
[go: up one dir, main page]

Skip to content

fix: Playground UI shows no edges when using KuzuDB backend #722

@tucaman

Description

@tucaman

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 the if source and target guard

Steps to Reproduce

  1. Configure KuzuDB backend: cgc config set DEFAULT_DATABASE kuzudb
  2. Index a repository: cgc index /path/to/repo
  3. Verify edges exist via CLI: cgc analyze callers ... or direct KuzuDB query confirms IMPORTS/CONTAINS edges
  4. Launch Playground: cgc visualize
  5. 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 _label from dict, filter _-prefixed internal keys from properties
  • Relationship processing: read _src/_dst/_label directly 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0