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(validate): accept edge-label vertices without width/height (#37)

Agents365.ai7bfef92f5ec2
diff --git a/skills/drawio-skill/scripts/validate.py b/skills/drawio-skill/scripts/validate.py
index 9256b53..9f3a918 100644
--- a/skills/drawio-skill/scripts/validate.py
+++ b/skills/drawio-skill/scripts/validate.py
@@ -39,6 +39,19 @@ def rect(cell):
return None
+def is_edge_label(cell):
+ """True for a draw.io edge label / relative-positioned child vertex.
+
+ These legitimately omit width/height: their position is given relative to a
+ parent edge (style ``edgeLabel``) or via ``relative="1"`` geometry. Treating
+ them as normal vertices wrongly flags them as missing/invalid geometry.
+ """
+ if "edgeLabel" in (cell.get("style") or ""):
+ return True
+ g = cell.find("mxGeometry")
+ return g is not None and g.get("relative") == "1"
+
+
def overlap(a, b):
ax, ay, aw, ah = a
bx, by, bw, bh = b
@@ -74,7 +87,7 @@ def check_page(diagram):
errors.append(f"edge {cid!r} {end} {ref!r} does not exist")
if (is_v or is_e) and cid in RESERVED:
errors.append(f"cell {cid!r} reuses reserved id 0/1")
- if is_v:
+ if is_v and not is_edge_label(c):
r = rect(c)
if r is None or any(v != v for v in r): # None or NaN
errors.append(f"vertex {cid!r} has missing/invalid geometry")
diff --git a/tests/test_scripts.py b/tests/test_scripts.py
index d385498..9c21d3d 100644
--- a/tests/test_scripts.py
+++ b/tests/test_scripts.py
@@ -175,6 +175,20 @@ class TestValidateCli(unittest.TestCase):
'<mxCell id="4" edge="1" parent="1" source="2" target="nope">'
'<mxGeometry relative="1" as="geometry"/></mxCell>'
'</root></mxGraphModel></diagram></mxfile>')
+ # Edge label: a relative-positioned vertex that legitimately omits width/height.
+ EDGE_LABEL = ('<mxfile><diagram name="P1"><mxGraphModel><root>'
+ '<mxCell id="0"/><mxCell id="1" parent="0"/>'
+ '<mxCell id="2" value="A" vertex="1" parent="1">'
+ '<mxGeometry x="0" y="0" width="80" height="40" as="geometry"/></mxCell>'
+ '<mxCell id="3" value="B" vertex="1" parent="1">'
+ '<mxGeometry x="200" y="0" width="80" height="40" as="geometry"/></mxCell>'
+ '<mxCell id="4" edge="1" parent="1" source="2" target="3">'
+ '<mxGeometry relative="1" as="geometry"/></mxCell>'
+ '<mxCell id="5" value="lbl" style="edgeLabel;html=1;" vertex="1" '
+ 'connectable="0" parent="1">'
+ '<mxGeometry x="0.5" y="0" relative="1" as="geometry">'
+ '<mxPoint as="offset"/></mxGeometry></mxCell>'
+ '</root></mxGraphModel></diagram></mxfile>')
def _check(self, xml):
with tempfile.NamedTemporaryFile("w", suffix=".drawio", delete=False) as f:
@@ -193,6 +207,13 @@ class TestValidateCli(unittest.TestCase):
self.assertEqual(r.returncode, 1)
self.assertIn("error", r.stdout)
+ def test_edge_label_passes(self):
+ # edgeLabel vertices have no width/height; they must not be flagged
+ # as missing/invalid geometry (issue #35).
+ r = self._check(self.EDGE_LABEL)
+ self.assertEqual(r.returncode, 0)
+ self.assertNotIn("error:", r.stdout)
+
class TestImportersCli(unittest.TestCase):
@staticmethod