You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
to_graphml crashes on dict/list-valued attributes (node metadata, graph-level hyperedges) #1831
graphify export graphml crashes on any graph that has a dict or list-valued attribute — e.g. a per-node metadata dict, or the graph-level hyperedges list set by attach_hyperedges():
TypeError: GraphML does not support type <class 'dict'> as data values.
TypeError: GraphML does not support type <class 'list'> as data values.
nx.write_graphml only accepts scalar attribute values. to_graphml already coerces None -> "" for this exact reason (a prior fix for #1502), but dict/list values weren't handled the same way.
Repro
importnetworkxasnxfromgraphify.exportimportto_graphmlG=nx.Graph()
G.add_node("a", metadata={"kind": "file"})
G.add_node("b")
G.add_edge("a", "b")
G.graph["hyperedges"] = [{"nodes": ["a", "b"], "label": "x"}]
to_graphml(G, {0: ["a", "b"]}, "/tmp/out.graphml")
# TypeError: GraphML does not support type <class 'list'> as data values.
Also reproduces on a real ~2,300-node/4,300-edge project graph (not just this synthetic case) — every export attempt fails, and a failed attempt leaves a 0-byte .graphml file on disk that downstream tooling can mistake for a completed (if empty) export.
Fix
Opened #1830: extends to_graphml's existing None-scrubbing step to also JSON-serialize dict/list-valued attributes across graph-level, node, and edge scopes before calling nx.write_graphml. Includes a regression test mirroring the existing None-value test.
Fixed in a46eee4 (ships in 0.9.14). to_graphml now coerces None -> "" and JSON-serializes dict/list (and any other non-scalar) values across graph-level, node, and edge scopes, while GraphML-native int/float/bool/str pass through unchanged. Also addressed the 0-byte-file hazard you flagged: the export now writes to a sibling temp file and os.replaces it on success, so a failed export can't leave a partial/empty .graphml behind. Verified with a round-trip read (dict/list come back as JSON, scalars keep their types) plus a regression test. Thanks for the clean repro and for spotting the partial-file issue too, @hofmockel.
Activity
safishamsi commentedon Jul 12, 2026
Fixed in
a46eee4(ships in 0.9.14).to_graphmlnow coercesNone -> ""and JSON-serializes dict/list (and any other non-scalar) values across graph-level, node, and edge scopes, while GraphML-native int/float/bool/str pass through unchanged. Also addressed the 0-byte-file hazard you flagged: the export now writes to a sibling temp file andos.replaces it on success, so a failed export can't leave a partial/empty.graphmlbehind. Verified with a round-trip read (dict/list come back as JSON, scalars keep their types) plus a regression test. Thanks for the clean repro and for spotting the partial-file issue too, @hofmockel.fix(export): coerce non-scalar attrs in graphml; harden pipe-close flush
Merge v8 into falkordb-backend: re-port FalkorDB onto the new cli.py
fix: port the remaining v8 tests onto the FalkorDB backend
fix(export): coerce non-scalar attrs in graphml; harden pipe-close flush