graphs.visualization: activity names with &, < or > break graph rendering and export #2

Open
opened 2026-10-06 13:44:16 +00:00 by ffrauenberger · 0 comments
Owner

Severity: critical (one such character in an activity name stops the graph from rendering)

Where

  • app/graphs/visualization/directly_follows_graph.py:36, :121
  • app/graphs/visualization/petri_net_graph.py:40
  • app/graphs/visualization/bpmn_graph.py:82
  • app/components/interactiveGraph/frontend/src/InteractiveGraph.tsx:89-97

Problem

All node labels are built as Graphviz HTML-like labels by inserting the raw activity name:

label = f'<{title}<br/><font color="red">{absolute_frequency}</font>>'

Graphviz parses these labels as XML, so &, < and > must be escaped (&amp;, &lt;, &gt;). They are not. Real-world logs often contain names like R&D, Check amount > 1000 or <unknown>, and any one of them makes the whole graph fail to render.

Verified with the local dot binary:

label=<R&D review<br/>…>      -> Error: not well-formed (invalid token) … in label of node R&D review
label=<Amount > 1000<br/>5>   -> Error: syntax error in line 1 near '>'
label=<a<b<br/>5>             -> Error: syntax error … scanning a HTML string

Fuzzy miner cluster labels use the same pattern. Their content is generated today, but it is equally fragile.

Steps to reproduce

  1. Open the application
  2. Import a CSV log that contains an activity named R&D review (or Amount > 1000)
  3. Mine a model with any algorithm
  4. Open the Export page and export the graph

Expected behavior

The graph is rendered and exported, with the activity name shown as written.

Actual behavior

  • Interactive view: renderDot fails, the "end" event never fires, and the overlay "The Graph is being rendered…" stays forever. No error is shown.
  • Export page: graphviz.render() raises CalledProcessError, which ExportController.run does not catch. The user sees a Streamlit exception page.

Related: #51 (root cause).

Fix

  • Escape activity names with html.escape(title, quote=True) in one central helper in BaseGraph, used by every HTML-label builder.
  • In the frontend, add an error handler (.onerror(...) on the d3-graphviz instance or try/catch around renderDot) and show the error instead of the endless spinner.
  • In ExportController, catch graphviz.backend.CalledProcessError / ExecutableNotFound and report it.

from issues/BUG-002-graphviz-html-labels-not-escaped.md (code analysis of commit 6bcc646, 2026-10-03)

**Severity:** critical (one such character in an activity name stops the graph from rendering) ## Where - `app/graphs/visualization/directly_follows_graph.py:36`, `:121` - `app/graphs/visualization/petri_net_graph.py:40` - `app/graphs/visualization/bpmn_graph.py:82` - `app/components/interactiveGraph/frontend/src/InteractiveGraph.tsx:89-97` ## Problem All node labels are built as Graphviz *HTML-like* labels by inserting the raw activity name: ```python label = f'<{title}<br/><font color="red">{absolute_frequency}</font>>' ``` Graphviz parses these labels as XML, so `&`, `<` and `>` must be escaped (`&amp;`, `&lt;`, `&gt;`). They are not. Real-world logs often contain names like `R&D`, `Check amount > 1000` or `<unknown>`, and any one of them makes the whole graph fail to render. Verified with the local `dot` binary: ``` label=<R&D review<br/>…> -> Error: not well-formed (invalid token) … in label of node R&D review label=<Amount > 1000<br/>5> -> Error: syntax error in line 1 near '>' label=<a<b<br/>5> -> Error: syntax error … scanning a HTML string ``` Fuzzy miner cluster labels use the same pattern. Their content is generated today, but it is equally fragile. ### Steps to reproduce 1. Open the application 2. Import a CSV log that contains an activity named `R&D review` (or `Amount > 1000`) 3. Mine a model with any algorithm 4. Open the Export page and export the graph ### Expected behavior The graph is rendered and exported, with the activity name shown as written. ### Actual behavior - Interactive view: `renderDot` fails, the `"end"` event never fires, and the overlay *"The Graph is being rendered…"* stays forever. No error is shown. - Export page: `graphviz.render()` raises `CalledProcessError`, which `ExportController.run` does not catch. The user sees a Streamlit exception page. Related: #51 (root cause). ## Fix - Escape activity names with `html.escape(title, quote=True)` in one central helper in `BaseGraph`, used by every HTML-label builder. - In the frontend, add an error handler (`.onerror(...)` on the d3-graphviz instance or try/catch around `renderDot`) and show the error instead of the endless spinner. - In `ExportController`, catch `graphviz.backend.CalledProcessError` / `ExecutableNotFound` and report it. --- from `issues/BUG-002-graphviz-html-labels-not-escaped.md` (code analysis of commit 6bcc646, 2026-10-03)
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
ffrauenberger/ProcessIntel#2
No description provided.