Skip to content

Agent skill that turns natural language, code, Terraform/K8s, SQL, OpenAPI, AsyncAPI, Protobuf and GraphQL sources into editable, tested draw.io architecture diagrams: incremental sync, multi-view projection, drift diff, CI architecture tests, whiteboard derasterize, interactive HTML/PPTX/Mermaid exports.

fix(drawiodiff): NameError when an edge re-points its source

Anai-Guoeee63bdb33ed
diff --git a/skills/drawio-skill/scripts/drawiodiff.py b/skills/drawio-skill/scripts/drawiodiff.py
index c1c9f12..24b1096 100644
--- a/skills/drawio-skill/scripts/drawiodiff.py
+++ b/skills/drawio-skill/scripts/drawiodiff.py
@@ -134,7 +134,7 @@ def classify_rerouted(old_ek, new_ek, removed, added):
if len(cands) == 1:
rerouted.add(cands[0])
elif a in removed and b not in removed:
- cands = [(c, b) for (s, t) in new_only if t == b and s in added]
+ cands = [(s, b) for (s, t) in new_only if t == b and s in added]
if len(cands) == 1:
rerouted.add(cands[0])
return rerouted
diff --git a/tests/test_scripts.py b/tests/test_scripts.py
index ce339ac..331b44b 100644
--- a/tests/test_scripts.py
+++ b/tests/test_scripts.py
@@ -969,6 +969,33 @@ class TestImportersCli(unittest.TestCase):
self.assertIn("b85450", estatus[("api", "cache")]) # removed
self.assertIn("d79b00", estatus[("api", "worker")]) # rerouted
+ def test_drawiodiff_incoming_repoint_is_rerouted(self):
+ # Mirror of the case above, with the arrow the other way round: the
+ # (cache, api) edge re-points to (worker, api) — target kept, old
+ # source removed, new source added — so it is orange "rerouted" too.
+ old = self._drawio(
+ [("api", "api"), ("db", "db"), ("cache", "cache")],
+ [("db", "api"), ("cache", "api")],
+ )
+ new = self._drawio(
+ [("api", "api"), ("db", "db"), ("worker", "worker")],
+ [("db", "api"), ("worker", "api")],
+ )
+ with tempfile.TemporaryDirectory() as d:
+ self._write(os.path.join(d, "old.drawio"), old)
+ self._write(os.path.join(d, "new.drawio"), new)
+ graph = json.loads(
+ run(
+ "drawiodiff.py",
+ os.path.join(d, "old.drawio"),
+ os.path.join(d, "new.drawio"),
+ ).stdout
+ )
+ estatus = {(e["source"], e["target"]): e["style"] for e in graph["edges"]}
+ self.assertIn("999999", estatus[("db", "api")]) # same
+ self.assertIn("b85450", estatus[("cache", "api")]) # removed
+ self.assertIn("d79b00", estatus[("worker", "api")]) # rerouted
+
@staticmethod
def _drawio_pos(nodes, edges):
""".drawio XML from (id, label, x, y) nodes and (src, tgt) edges."""