Repository navigation
Description
Bug Report: graphify query crashes with ValueError
Environment
- graphifyy version: 0.3.29
- Python version: 3.13.3
- NetworkX version: 3.6.1
- OS: macOS
Bug Description
The graphify query command crashes with a ValueError when trying to render query results.
Error Message
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.13/bin/graphify", line 7, in <module>
sys.exit(main())
File "/private/tmp/graphify-temp/graphify/__main__.py", line 828, in main
print(_subgraph_to_text(G, nodes, edges, token_budget=budget))
~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/private/tmp/graphify-temp/graphify/serve.py", line 95, in _subgraph_to_text
d = G.edges[u, v]
~~~~~~~^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/networkx/classes/reportviews.py", line 1368, in __getitem__
u, v, k = e
^^^^^^^
ValueError: not enough values to unpack (expected 3, got 2)
Root Cause
In serve.py line 95:
d = G.edges[u, v]When the graph is a MultiGraph (which json_graph.node_link_graph creates by default when there are multiple edges between nodes), G.edges[u, v] returns a 3-tuple (u, v, key) instead of a 2-tuple.
The code at line 96 then tries to unpack it:
line = f"EDGE {sanitize_label(G.nodes[u].get('label', u))} --{d.get('relation', '')} [{d.get('confidence', '')}]--> {sanitize_label(G.nodes[v].get('label', v))}"But d is not a dict when the graph is a MultiGraph.
Steps to Reproduce
- Install graphify:
pip install graphifyy - Create a graph.json with multiple edges between nodes (or any non-trivial graph)
- Run:
graphify query "any query"
Workaround
Convert the graph to a regular Graph (non-MultiGraph) before saving:
G = nx.Graph(G) # Remove parallel edgesOr modify _subgraph_to_text to handle MultiGraph edges properly.
Suggested Fix
Option 1: Handle MultiGraph explicitly:
if G.is_multigraph():
d = G.edges[u, v, 0] # Get first edge's data
else:
d = G.edges[u, v]Option 2: Convert to simple Graph in _load_graph:
G = json_graph.node_link_graph(data, edges="links")
if G.is_multigraph():
G = nx.Graph(G) # Convert to simple graph
return GAdditional Context
The graph.json was generated successfully by the /graphify skill. The issue only occurs during the query command when traversing edges.
Repository: https://github.com/safishamsi/graphify
Activity
safishamsi commentedon Apr 13, 2026
Fixed in v0.4.11. Replaced
G.edges[u, v]withG[u][v]and added a MultiGraph guard — if the loaded graph is aMultiGraphorMultiDiGraph, the first edge's attributes are used vianext(iter(G[u][v].values()), {}).