JIRA allows for duplicate version names

XMLWordPrintable

    • 3.1
    • 2
    • 1

      When creating versions if you type a space after the version name and click Add the version will be created but the spaces created after the name are truncated. This allows for duplicate version names and can cause problems.

      The steps to reproduce this:

      • Add Version: 1.1.0
      • Add the same version again, but put a space or 2 after the version and click Add.
      • You will then have 2 - 1.1.0 versions.
      • If you Edit the details of the version created that had spaces added after it to change the date/description you will get a message that a version with that name already exists.

      Looking at the code I can see the problem. The validation logic in AddVersion and EditVersionDetails actions are inconsistent.

      AddVersion

      Collection versions = versionManager.getVersions(getPid());
      for (Iterator entityIter = versions.iterator(); entityIter.hasNext();)
      {
          Version version = (Version) entityIter.next();
          if (getName().equalsIgnoreCase(version.getName()))
          {
               addError("name", getText("admin.errors.version.already.exists"));
          }
      }
      

      then the name is stored as is, i.e. no truncation.

      Validation in EditVersionDetails calls isDuplicateName()

      //if the name already exists then add an Error message
      if (isDuplicateName())
      {
          addError("name", getText("admin.errors.projectversions.version.exists"));
      }
      

      and isDuplicate method trims the new version name when it compares it against existing version names

      if (!getVersionId().equals(version.getId()) && getName().trim().equalsIgnoreCase(version.getName()))
      

      We need to ensure that we use the same validation logic in all places. I personally think that we should not trim trailing spaces anywhere as we store them anyway.

            Assignee:
            Marcin Barzyk
            Reporter:
            Dushan Hanuska [Atlassian]
            Votes:
            2 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: