Uploaded image for project: 'Jira Platform Cloud'
  1. Jira Platform Cloud
  2. JRACLOUD-29704

When clone operation fails during create, a self-referencing cloners link is added to the original issue

      NOTE: This bug report is for JIRA Cloud. Using JIRA Server? See the corresponding bug report.

      Summary

      If a clone operation fails during the create transition (such as when a validator on the Create transition stops the issue creation), JIRA adds a self-referencing link to the original issue (only if the Cloners link type is specified, of course).

      Steps to Reproduce

      1. Create a validator such as Required Field(s) using JIRA Suite Utilities on the Create Issue Transition.
      2. Setup an issue so that it does not have those requirements. For example, set the requirement to affects version, then remove the affects version from the issue.
      3. Attempt to clone the issue.

      Expected Results

      The issue does not create a clone and notifies the user why.

      Actual Results

      The issue is not cloned, however an issue link is created to itself. Nothing notifies the user of failure.

      Workaround

      Fix the validator for that issue and then clone it. Using the above example that would mean adding an affects version.

      Notes

      After some investigation, this appears to be caused by the following code in the doExecute() method of the CloneIssueDetails class:

      // Create link between the cloned issue and the original - sequence on links does not matter.
      final IssueLinkType cloneIssueLinkType = getCloneIssueLinkType();
      if (cloneIssueLinkType != null)
      {
          issueLinkManager.createIssueLink(getOriginalIssue().getId(), getIssue().getLong("id"), cloneIssueLinkType.getLong("id"), null, getLoggedInUser());
      }
      

      By simply calling the getOriginalIssue() and getIssue() methods, there is a built-in assumption that the clone creation succeeded. However, if the creation failed, these two methods will return the same issue (originalIssue is first set using the getIssue() result).

      Please add a check here that the clone creation actually succeeded, or at least that getOriginalIssue() and getIssue() are resulting in different and valid issues.

            [JRACLOUD-29704] When clone operation fails during create, a self-referencing cloners link is added to the original issue

            Monique Khairuliana (Inactive) made changes -
            Workflow Original: JIRA Bug Workflow w Kanban v6 - Restricted [ 1867488 ] New: JAC Bug Workflow v3 [ 3360426 ]
            Status Original: Resolved [ 5 ] New: Closed [ 6 ]
            Eric S (Inactive) made changes -
            Component/s New: Issue [ 51491 ]
            Component/s Original: Issue - Clone [ 46601 ]
            jonah (Inactive) made changes -
            Description Original: h3. Summary

            If a clone operation fails during the create transition (such as when a validator on the Create transition stops the issue creation), JIRA adds a self-referencing link to the original issue (only if the Cloners link type is specified, of course).

            h3. Steps to Reproduce

            # Create a validator such as Required Field(s) using [JIRA Suite Utilities|https://marketplace.atlassian.com/plugins/com.googlecode.jira-suite-utilities] on the Create Issue Transition.
            # Setup an issue so that it does not have those requirements. For example, set the requirement to affects version, then remove the affects version from the issue.
            # Attempt to clone the issue.

            h3. Expected Results

            The issue does not create a clone and notifies the user why.

            h3. Actual Results

            The issue is not cloned, however an issue link is created to itself. Nothing notifies the user of failure.

            h3. Workaround

            Fix the validator for that issue and then clone it. Using the above example that would mean adding an affects version.

            h3. Notes
            After some investigation, this appears to be caused by the following code in the _doExecute()_ method of the *CloneIssueDetails* class:

            {code:java}
            // Create link between the cloned issue and the original - sequence on links does not matter.
            final IssueLinkType cloneIssueLinkType = getCloneIssueLinkType();
            if (cloneIssueLinkType != null)
            {
                issueLinkManager.createIssueLink(getOriginalIssue().getId(), getIssue().getLong("id"), cloneIssueLinkType.getLong("id"), null, getLoggedInUser());
            }
            {code}

            By simply calling the _getOriginalIssue()_ and _getIssue()_ methods, there is a built-in assumption that the clone creation succeeded. However, if the creation failed, these two methods will return the same issue (originalIssue is first set using the _getIssue()_ result).

            Please add a check here that the clone creation actually succeeded, or at least that _getOriginalIssue()_ and _getIssue()_ are resulting in different and valid issues.
            New: {panel:bgColor=#e7f4fa}
              *NOTE:* This bug report is for *JIRA Cloud*. Using *JIRA Server*? [See the corresponding bug report|http://jira.atlassian.com/browse/JRASERVER-29704].
              {panel}

            h3. Summary

            If a clone operation fails during the create transition (such as when a validator on the Create transition stops the issue creation), JIRA adds a self-referencing link to the original issue (only if the Cloners link type is specified, of course).

            h3. Steps to Reproduce

            # Create a validator such as Required Field(s) using [JIRA Suite Utilities|https://marketplace.atlassian.com/plugins/com.googlecode.jira-suite-utilities] on the Create Issue Transition.
            # Setup an issue so that it does not have those requirements. For example, set the requirement to affects version, then remove the affects version from the issue.
            # Attempt to clone the issue.

            h3. Expected Results

            The issue does not create a clone and notifies the user why.

            h3. Actual Results

            The issue is not cloned, however an issue link is created to itself. Nothing notifies the user of failure.

            h3. Workaround

            Fix the validator for that issue and then clone it. Using the above example that would mean adding an affects version.

            h3. Notes
            After some investigation, this appears to be caused by the following code in the _doExecute()_ method of the *CloneIssueDetails* class:

            {code:java}
            // Create link between the cloned issue and the original - sequence on links does not matter.
            final IssueLinkType cloneIssueLinkType = getCloneIssueLinkType();
            if (cloneIssueLinkType != null)
            {
                issueLinkManager.createIssueLink(getOriginalIssue().getId(), getIssue().getLong("id"), cloneIssueLinkType.getLong("id"), null, getLoggedInUser());
            }
            {code}

            By simply calling the _getOriginalIssue()_ and _getIssue()_ methods, there is a built-in assumption that the clone creation succeeded. However, if the creation failed, these two methods will return the same issue (originalIssue is first set using the _getIssue()_ result).

            Please add a check here that the clone creation actually succeeded, or at least that _getOriginalIssue()_ and _getIssue()_ are resulting in different and valid issues.
            jonah (Inactive) made changes -
            Link New: This issue is related to JRASERVER-29704 [ JRASERVER-29704 ]
            vkharisma made changes -
            Project Import New: Sat Apr 01 19:36:47 UTC 2017 [ 1491075407146 ]
            Confluence Escalation Bot (Inactive) made changes -
            Confluence Escalation Bot (Inactive) made changes -
            Marty Henderson (Inactive) made changes -
            Oswaldo Hernandez (Inactive) made changes -
            Owen made changes -

              pklimkowski@atlassian.com Piotr Klimkowski (Inactive)
              7ce5f856ba69 Kavian Moradhassel
              Affected customers:
              25 This affects my team
              Watchers:
              27 Start watching this issue

                Created:
                Updated:
                Resolved: