Skip to content

fix(viz): match backend internal keys case-insensitively (#1458) - #1471

Closed
Shashankss1205 wants to merge 1 commit into
mainfrom
fix/1458-ladybug-uppercase-keys
Closed

fix(viz): match backend internal keys case-insensitively (#1458)#1471
Shashankss1205 wants to merge 1 commit into
mainfrom
fix/1458-ladybug-uppercase-keys

Conversation

@Shashankss1205

Copy link
Copy Markdown
Collaborator

Closes #1458

The offline renderer's four parsing helpers keyed only on the lowercase internal fields Kùzu returns (_label/_src/_dst/_id). LadybugDB returns the same fields uppercase (_LABEL/_SRC/_DST/_ID), so no dict branch matched, every value was discarded, and the renderer bailed out with No graph data returned — index a repository first against a database that demonstrably held data.

Adds _meta() / _has_meta() helpers accepting either casing, and routes all four helpers through them.

Deliberately additive and low-risk: both helpers try the lowercase spelling first and only then uppercase, so the Kùzu, Neo4j and Falkor code paths are byte-for-byte unchanged. Mixed casing inside a single record also works, since each field resolves independently.

One intentional behaviour change, called out explicitly: an empty-or-missing _label now falls back to Node/RELATED, whereas previously only a missing key hit the default and a present-but-empty one propagated "".

Tests add the Ladybug uppercase shape to the existing backend-shape parametrisation, plus three cases: uppercase records render, mixed casing renders, and an uppercase relationship is still not misclassified as a node (_LABEL alone must not decide — _SRC/_DST does).

Verified: 944 passed, 7 skipped, 0 failed across tests/unit.

⚠️ Touches the same four helpers as #1453 (real FalkorDB Node/Edge shape). They are complementary — different backends, different failure — but will conflict textually. Merge #1453 first, then rebase this one.

🤖 Generated with Claude Code

The offline renderer's four parsing helpers keyed only on the lowercase
internal fields Kuzu returns (_label/_src/_dst/_id). LadybugDB returns the
same fields uppercase (_LABEL/_SRC/_DST/_ID), so no dict branch matched, every
value was discarded, and _render_offline_visualization bailed out with
'No graph data returned - index a repository first' against a database that
demonstrably held data.

Adds _meta()/_has_meta() helpers that accept either casing, and routes the
four helpers through them.

Deliberately additive: both helpers try the lowercase spelling first and only
then the uppercase one, so the Kuzu, Neo4j and Falkor paths are unchanged.
Mixed casing within a single record also works, since each field is resolved
independently.

One intentional behaviour change: an empty or missing _label now falls back to
'Node'/'RELATED' rather than propagating '' - previously only a *missing* key
hit the default.

Tests add the Ladybug uppercase shape to the existing backend-shape
parametrisation plus three cases: uppercase records render, mixed casing
renders, and an uppercase relationship is still not misclassified as a node
(_LABEL alone must not decide - _SRC/_DST does).

Verified: 944 passed, 7 skipped, 0 failed across tests/unit.

Closes #1458

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 29, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
code-graph-context-pack Ready Ready Preview Jul 29, 2026 11:05pm

@github-actions

Copy link
Copy Markdown
Contributor

Hi! 👋 Join our CodeGraphContext Discord channel to collaborate: https://discord.gg/dR4QY32uYQ

@github-actions

Copy link
Copy Markdown
Contributor

🔍 PR Code Graph Analysis

fix(viz): match backend internal keys case-insensitively (#1458) (#1471)

📊 Interactive Visualization

View the blast radius graph: PR Reviewer Dashboard

📦 Artifacts

The graph JSON has been uploaded as a build artifact: pr-code-graph-1471


Generated by CodeGraphContext using FalkorDB Lite

@github-project-automation github-project-automation Bot moved this from Backlog tasks to Done in CGC Progress Board Jul 29, 2026
Shashankss1205 added a commit that referenced this pull request Aug 5, 2026
…_DST) (#1506)

Closes #1458.

KùzuDB and LadybugDB share the same embedded-graph wire format (plain
dict records), but LadybugDB spells its internal metadata fields
uppercase (_ID/_LABEL/_SRC/_DST) where KùzuDB spells the same fields
lowercase (_id/_label/_src/_dst). Confirmed empirically against both
real packages:

    # real ladybug package, MATCH (n)-[r]->(m) RETURN n, r, m
    >>> list(node_row.keys())
    ['_ID', '_LABEL', 'name', 'path']
    >>> list(rel_row.keys())
    ['_SRC', '_DST', '_LABEL', '_ID']

    # real kuzu package, same query
    >>> list(node_row.keys())
    ['_id', '_label', 'name', 'path']
    >>> list(rel_row.keys())
    ['_src', '_dst', '_label', '_id']

`cli_helpers.py`'s offline-viz helpers (`_is_node`, `_is_relationship`,
`_node_payload`, `_edge_payload`) only checked the lowercase spelling,
so every LadybugDB row was silently discarded and
`_render_offline_visualization` bailed out with "No graph data
returned" even on a freshly indexed repo — exit code 1.

The same gap exists, unaddressed, in `viz/server.py` — the live web
visualization server (the flagship FastAPI-served graph UI, not just
the CLI fallback). `_get_eid`, the inline `/api/graph` node/edge
parsing, and the standalone `parse_node`/`parse_rel`/`parse_element`
helpers all had the identical lowercase-only checks, so a LadybugDB
backend renders an empty live graph too. This file was not touched by
the earlier attempt at this issue (#1471, closed unmerged).

Adds a small `_meta()`/`_has_meta()` helper in each file that reads a
backend-internal field regardless of casing, and uses it everywhere
the four fields are read. KùzuDB/Neo4j/FalkorDB behavior is untouched
(lowercase-first, upper as fallback).

Verified end-to-end against the real `ladybug` package, not just unit
tests: indexed a sample repo with LADYBUGDB as the active backend and
ran `cgc visualize`.

  Before: No graph data returned — index a repository first
  After:  Rendered 8 nodes and 9 edges to /tmp/cgc_graph_....html

Unit tests: added a LadybugDB fixture (uppercase keys) to the existing
parametrized offline-viz test, and a new
tests/unit/viz/test_server_graph_parsing.py covering `_get_eid`,
`_meta`, `parse_node`, `parse_rel`, and `parse_element` against both
KùzuDB and LadybugDB shapes. Confirmed all new cases fail on the
pre-fix code before reapplying the fix.

Co-authored-by: Shashank Shekhar Singh <Shashankshekharsingh1205@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Bug - Offline visualization fails on LadybugDB/Kùzu due to case-sensitive internal key parsing

1 participant