Skip to content

Creating a workflow with the same name as another that is pending deletion is confusing #4156

@lmac-1

Description

@lmac-1

Describe the bug
If you create a workflow with the name of a workflow previously deleted in the project, you will get the validation message "a workflow with this name already exists in this project".
Found when working on #4138.

Proposed fix

  1. Change the validation message to say. "There is another workflow in this project (possibly pending deletion) with the same name." It's just not that big a deal for a user to slightly change the name to pass validation as long as they're not spooked out/think we're wrong about the validation error.
  2. On delete, we change the name of the workflow that is deleted. The elixir delete_workflow action (or whatever it's called) would append _del{++ integer if required} to the end of the workflow name.

Version number v2.15.0-pre3

I have reproduced this locally on main:

  • Yes
  • No

To Reproduce Steps to reproduce the behavior:

  1. Create a new workflow in a project
  2. Open the workflow in collaborative editor
  3. Open workflow settings panel (click settings icon in header) and rename the workflow to something memorable (e.g. "Bug test"). Make a note of the name including case.
  4. Go back to the "Workflows" page
  5. Delete this workflow
  6. Create a new workflow in the same project
  7. Open the workflow in collaborative editor
  8. Open the workflow settings panel (click settings icon in header) and rename workflow to the same name as step 3 (e.g. "Bug test"). Note: this field is case sensitive, so it must be exactly as you wrote it in step 3

Expected behaviour You can save the workflow with the same name
Actual behaviour Validation message appears "a workflow with this name already exists in this project."

Screenshots

Image

But there is no workflow called "Delete" in that project (I deleted it before):

Image

Additional context
When workflows are deleted, they are soft deleted and instead of hard deleting, we update the deleted_at field. This code in workflow.ex is what is validating:

def validate(changeset) do
    changeset
    |> assoc_constraint(:project)
    |> validate_number(:concurrency, greater_than_or_equal_to: 1)
    |> validate_required([:name])
    |> unique_constraint([:name, :project_id],
      message: "a workflow with this name already exists in this project."
    )
  end

That's good. Keep it simple. No two workflows (no matter if they're red or blue or happy or sad or active or archived or pending deletion or whatever) in the same project can have the same name.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions