Skip to content

query/path/explain fail when graph.json uses edges instead of links #768

Closed

Description

@gudzenkov

Summary

graphify query fails to load a graph.json that contains edges but no links:

error: could not load graph: 'links'

This looks like the same node-link key compatibility class as #738, but affecting the query/path/explain loading paths.

Environment

  • Package: graphifyy
  • Version observed: 0.7.9
  • Python: 3.12.3
  • OS/runtime: Linux aarch64
  • NetworkX installed by uvx --from graphifyy

Reproduction

  1. Generate or obtain a graph.json shaped like this:
{
  "nodes": [{"id": "a", "label": "A"}, {"id": "b", "label": "B"}],
  "edges": [{"source": "a", "target": "b", "relation": "calls"}],
  "hyperedges": []
}
  1. Run:
uvx --from graphifyy graphify query "A" --graph graph.json

Actual behavior

error: could not load graph: 'links'

In my repo benchmark, the generated graph artifact had content but only an edges key:

nodes: 694
edges: 1993
links key present: false

Copying edges to links made graphify query load the same graph, so this is not a partial-index problem; it is a loader/schema compatibility problem.

Expected behavior

graphify query, graphify path, and graphify explain should accept both historical/current node-link edge keys:

  • links
  • edges

If links is missing and edges is present, the loader should normalize the input before calling networkx.readwrite.json_graph.node_link_graph(..., edges="links"), or otherwise call NetworkX with the matching edge-key name.

Likely fix

Use a tolerant node-link loader everywhere query/path/explain load a graph, similar to the merge compatibility fix from #738:

def _load_node_link(data):
    if "links" not in data and "edges" in data:
        data = dict(data, links=data["edges"])
    try:
        return json_graph.node_link_graph(data, edges="links")
    except TypeError:
        return json_graph.node_link_graph(data)

The important bit is to handle KeyError: 'links' / missing-key compatibility, not just the NetworkX-version TypeError fallback.

Related

Activity

  1. safishamsi commented on May 7, 2026

    @safishamsi
    Member

    Fixed in aa2bd13 - added edges→links normalization to all four load sites: query, path, explain in __main__.py and _load_graph in serve.py. Same pattern as the #738 fix for merge-graphs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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