eclipse-sirius / sirius-web

Sirius Web: open-source low-code platform to define custom web applications supporting your specific visual languages
https://eclipse.dev/sirius/sirius-web.html
Eclipse Public License 2.0
79 stars 52 forks source link

ExplorerNavigationService#getAncestors fails on non-UUID selectionEntryId #2436

Open gdaniel opened 1 year ago

gdaniel commented 1 year ago

The following line in ExplorerNavigationService produces an IllegalArgumentException when the selectioEntryId String is not an UUID.

var optionalRepresentation = this.representationService.getRepresentation(UUID.fromString(selectionEntryId));

The exception is thrown by UUID.fromString(String).

Note that ObjectService#getId(Object) can return a non-UUID String (e.g. a URI fragment), and the getAncestors method can handle non-UUID IDs in the following line:

var optionalSemanticObject = this.objectService.getObject(editingContext, selectionEntryId);

It seems that the method shouldn't look for a RepresentationDescriptor if selectionEntryId is not a valid UUID.

Screenshots

Relevant stack trace

Caused by: java.lang.IllegalArgumentException: Invalid UUID string: UML.metamodel.uml#ReduceAction
    at java.base/java.util.UUID.fromString1(UUID.java:280) ~[na:na]
    at java.base/java.util.UUID.fromString(UUID.java:258) ~[na:na]
    at org.eclipse.sirius.web.services.explorer.ExplorerNavigationService.getAncestors(ExplorerNavigationService.java:51) ~[sirius-web-services-2023.8.3.jar:2023.8.3]
    at org.eclipse.sirius.web.services.explorer.ExplorerTreePathProvider.handle(ExplorerTreePathProvider.java:54) ~[sirius-web-services-2023.8.3.jar:2023.8.3]
    at org.eclipse.sirius.components.collaborative.trees.handlers.TreePathEventHandler.handle(TreePathEventHandler.java:71) ~[sirius-components-collaborative-trees-2023.8.3.jar:2023.8.3]
    at org.eclipse.sirius.components.collaborative.trees.TreeEventProcessor.handle(TreeEventProcessor.java:118) ~[sirius-components-collaborative-trees-2023.8.3.jar:2023.8.3]

Steps to reproduce

Call ExplorerNavigationService#getAncestors with a non-UUID selectionEntryId.

Expected behavior

ExplorerNavigationService#getAncestors returns the list of ancestors or an empty list when the selectionEntryId is a non-UUID String.

Actual behavior

ExplorerNavigationService#getAncestors throws an IllegalArgumentException.

sbegaudeau commented 1 year ago

Just a couple of comments:

While Sirius Components allows any String, Sirius Web uses UUID all the time. In order to match more closely what can be expressed with Sirius Components, we should support String instead of UUID as the identifier of the representation (even if we keep storing a UUID in said string). We should thus change RepresentationDescriptor#id, the repository, the database schema etc.