Skip to content

Commit c16db87

Browse files
author
miranov25
committed
fix(aliases): handle cycle detection in dependency graph
Add NetworkXUnfeasible to exception handling in select_aliases() when sorting aliases topologically. Cycles or graph issues now fall back to unordered list instead of crashing. Fixes describe_aliases(with_dependencies=True) crash when alias graph contains cycles or broken references.
1 parent 1ab1a38 commit c16db87

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

UTILS/dfextensions/AliasDataFrame/AliasDataFrame.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1584,7 +1584,9 @@ def build_graph():
15841584
try:
15851585
ordered = list(nx.topological_sort(g.subgraph(expanded)))
15861586
result = [n for n in ordered if n in expanded]
1587-
except nx.NetworkXError:
1587+
# Change to:
1588+
except (nx.NetworkXError, nx.NetworkXUnfeasible):
1589+
# Cycle detected or graph issue, return unordered
15881590
result = list(expanded)
15891591

15901592
return result

0 commit comments

Comments
 (0)