Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Validate that all step IDs are unique #189

Closed
amitgalitz opened this issue Nov 22, 2023 · 2 comments · Fixed by #191
Closed

[BUG] Validate that all step IDs are unique #189

amitgalitz opened this issue Nov 22, 2023 · 2 comments · Fixed by #191
Assignees
Labels
bug Something isn't working

Comments

@amitgalitz
Copy link
Member

What is the bug?

Currently we are allowed to create a template where we have duplicate step IDs throughout the steps. It would be beneficial to ensure these step IDs are unique so they can be used to identify different steps, especially in the resources created section.

This can be crucial for users wanting to know which step they listed corresponds to the created resource id.

Solution:

We can add validation to make sure all step_id's are unique, this can be done by adding the step_id to a set and make sure we don't have duplicates.

@amitgalitz amitgalitz added bug Something isn't working untriaged labels Nov 22, 2023
@dbwiddis
Copy link
Member

The topological sorter uses a map internally when sorting the nodes:

Map<String, ProcessNode> idToNodeMap = new HashMap<>();

So while there is a bug, it's far worse than just the resources created. It totally messes up the logic of the sorting, combining edges and other nastiness.

Easy fix is to check if the key exists here before putting in the map.

@dbwiddis
Copy link
Member

Actually, that won't work, the ids are already unique in the topological sorting from here:

Set<String> nodeIds = workflowNodes.stream().map(n -> n.id()).collect(Collectors.toSet());

So the fix is to compare the size of that set to the size of workflowNodes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants