Skip to content

Give slices whose names are not PlantUML ids an id of their own - #510

Merged
mak638 merged 1 commit into
mainfrom
fix/sanitize-slice-ids-for-plantuml
Oct 9, 2026
Merged

mak638 merged 1 commit into
mainfrom
fix/sanitize-slice-ids-for-plantuml

Conversation

@alexanderlinne

Copy link
Copy Markdown
Collaborator

The exporter uses a slice's name as its PlantUML id, but not every name is a valid one. PlantUML rejects *, +, `, < and
> in an id,

[Inner] as App.Outer+Inner syntax error
Container(App.Outer+Inner, Inner) error box instead of a container

and slice names can contain them: SlicedBy names slices after type names such as Outer+Inner or List`1, and a hand-built SliceIdentifier can be called anything. Only the flat, non-C4 form [App.Outer+Inner] happens to work, because it declares no id.

No character a namespace cannot contain works in their place: of -$#~:%@!^ only $ is accepted, and only outside C4. So give such a slice an id of its own when the diagram is rendered: its name with every character other than letters, digits, _ and . replaced by _, suffixed until it clashes with no other name in the diagram, and point the dependencies at it. The name stays the label, and a slice whose name is a valid id keeps it, so no existing diagram changes. The ids are assigned when rendering because the exporter matches slices and dependencies by name throughout.

A * at the start of a label is read as a list bullet and dropped, so it is escaped as ~*.

2-ids-for-non-id-names

The exporter uses a slice's name as its PlantUML id, but not every name
is a valid one. PlantUML rejects "*", "+", "`", "<" and ">" in an id,

  [Inner] as App.Outer+Inner           syntax error
  Container(App.Outer+Inner, Inner)    error box instead of a container

and slice names can contain them: SlicedBy names slices after type
names such as "Outer+Inner" or "List`1", and a hand-built
SliceIdentifier can be called anything. Only the flat, non-C4 form
"[App.Outer+Inner]" happens to work, because it declares no id.

No character a namespace cannot contain works in their place: of
"-$#~:%@!^" only "$" is accepted, and only outside C4. So give such a
slice an id of its own when the diagram is rendered: its name with
every character other than letters, digits, "_" and "." replaced by
"_", suffixed until it clashes with no other name in the diagram, and
point the dependencies at it. The name stays the label, and a slice
whose name is a valid id keeps it, so no existing diagram changes. The
ids are assigned when rendering because the exporter matches slices and
dependencies by name throughout.

A "*" at the start of a label is read as a list bullet and dropped, so
it is escaped as "~*".

Signed-off-by: Alexander Linne <alexander.linne@tngtech.com>
@alexanderlinne alexanderlinne changed the title fix: give slices whose names are not PlantUML ids an id of their own Give slices whose names are not PlantUML ids an id of their own Oct 9, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.32%. Comparing base (192657e) to head (12209be).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #510      +/-   ##
==========================================
+ Coverage   86.25%   86.32%   +0.06%     
==========================================
  Files         260      260              
  Lines       12500    12563      +63     
  Branches     1218     1225       +7     
==========================================
+ Hits        10782    10845      +63     
  Misses       1379     1379              
  Partials      339      339              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mak638
mak638 merged commit ce36224 into main Oct 9, 2026
10 checks passed
@mak638
mak638 deleted the fix/sanitize-slice-ids-for-plantuml branch October 9, 2026 10:04
This was referenced Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants