Files
agent-framework/dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests
T
Ben Thomas db48f8ce09 .NET: Fixing issue with invalid node Ids when visualizing dotnet workflows. (#4269)
* Fix Mermaid rendering errors in WorkflowVisualizer.ToMermaidString

Fix two bugs in the Mermaid diagram output:

1. Use safe node aliases (node_0, node_1, ...) instead of raw executor IDs
   as Mermaid node identifiers. Raw IDs containing spaces, dots, or
   non-ASCII characters (e.g. Japanese) caused Mermaid parse errors.

2. Fix conditional edge arrow syntax from '.--> ' (invalid) to '.-> '
   (valid Mermaid dotted arrow syntax).

Fixes #1406

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Use recognizable sanitized IDs for Mermaid node identifiers\n\nReplace generic node_0/node_1 aliases with IDs derived from the original\nexecutor names. ASCII letters, digits, and underscores are preserved;\nother characters become underscores (collapsed, trimmed). Leading digits\nget an n_ prefix. Collisions are resolved with a numeric suffix.\n\nThis keeps node IDs readable in the Mermaid source while the display\nlabels continue to show the full original names."

* Remove issue number references from test names and comments"

* Address PR review feedback from Copilot\n\n- Add Throw.IfNull(id) guard to SanitizeMermaidNodeId\n- Add safety limit (10,000) to collision resolution loop\n- Restore missing edge assertions (middle1/middle2 --> end)\n- Fix comment to show actual sanitized ID (n_1_User_input)\n- Use stricter regex in Unicode test (must start with letter/underscore)"

* Address second round of PR review feedback\n\n- Escape node display labels via EscapeMermaidLabel to handle quotes,\n  brackets, and newlines in executor IDs\n- Fix XML doc on SanitizeMermaidNodeId to accurately describe that\n  existing consecutive underscores in input are preserved\n- Restore specific edge assertion (mid --> end) in conditional edge test\n- Restore fan-in routing assertions (s1/s2 through intermediate node,\n  no direct edges to t) in fan-in test"

---------

Co-authored-by: alliscode <bentho@microsoft.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
db48f8ce09 ยท 2026-03-02 16:26:14 +00:00
History
..