Automation creates duplicates when cloning

Alex Dokhtiar November 7, 2024

I have pretty simple automation with the following logic:

When issue in project X is transitioned into certain status then this issue is cloned into the other project.

Here is how it looks like:

Screenshot 2024-11-07 at 10.56.00.png

I have added an additional check for linked issues to ensure rule is not triggered when issue was already cloned once. This rule works fine when I create an issue in "Open" status and then transition it into "PROD investigation".

The problem appears when status 'PROD investigation' is chosen during the issue creation. In this case issues is cloned twice meaning that by some reason rule is triggered twice.

I've tried adding delay before "Then", tried setting 'from' statuses in the trigger and couple of other options and nothing seems to work.

Am I missing something? Thank you in advance.

3 answers

1 accepted

0 votes
Answer accepted
Alex Dokhtiar November 12, 2024

With the help of @Bill Sheboy I've managed to make it work. You'd need two separate rules: for creation and for transition.

Screenshot 2024-11-12 at 17.39.29.pngScreenshot 2024-11-12 at 17.39.53.png

0 votes
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 7, 2024

Hi @Alex Dokhtiar 

When an issue is created in a status other than the first in the workflow, it does that in two steps:

  1. create the issue
  2. transition the issue

This can be observed in the issue history.

 

Do you have two rules, where one is triggered on Issue Created and another is on Issue Transitioned?  If so, for this scenario you would not need the Issue Created rule.

If that is not the case, please post:

  • an image of the complete audit log entries and
  • images of the audit log details for two rule executions for the newly created issue

 

Kind regards,
Bill

Alex Dokhtiar November 8, 2024

Hi @Bill Sheboy , thank you for the reply.

 

I don't have two separate rules, by some reason trigger happens twice within this automation.

 

Here is an image of the audit log within the ruleScreenshot 2024-11-08 at 11.13.29.png

It appears that, for some reason, the rule is being triggered not only on transition but also on creation, which shouldn’t be happening and I don't know how to avoid this from happening.

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 8, 2024

Thanks for that information and I just recreated the symptom.  I found this open defect for the symptom: https://jira.atlassian.com/browse/AUTO-916

I hypothesize the root cause is in the updated REST API endpoint for issue create as it may be raising the event twice: once on create and once on transition.  Worse still for your scenario, the cloning adds linking (which is another slow operation) and so passes the condition due to rule timing problems between the two rule triggerings.

The workaround in the defect is not helpful: disable the feature to allow transition on create.

 

Some other workarounds to try could be:

  • after the trigger, add the Re-fetch Issue action (rather than using the Delay one) to both slow the rule and reload the data
  • rather than using the Related Issues Condition, do this in two steps to perform the check
    • use Lookup Issues with JQL to get the possible existing clone
    • use the Smart Values Condition to test that {{lookupIssues.size}} equals 0 before trying to add the clone

 

Like Alex Dokhtiar likes this
Alex Dokhtiar November 8, 2024

Hi Bill, thanks a lot for your help. It makes total sense now. I will try mentioned workaround next week and post the update.

Alex Dokhtiar November 11, 2024

Hi @Bill Sheboy ,

Unfortunately, it still doesn't work as expected and duplicates are created.

Screenshot 2024-11-11 at 10.37.32.pngScreenshot 2024-11-11 at 10.37.24.png

 

Looks like there is no workaround. Anyway, thank you for the help!

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 11, 2024

Okay, let's go "brute force" to solve this: two rules, one for create transitions, and one for non-create transitions.

1) Create a rule, triggered on Issue Created, and check the status with a condition.  Then check existence and perform the clone.

2) To fix the rule triggered on Issue Transitioned, let's return to your original rule with these adjustments:

  • trigger: issue transitioned
  • action: re-fetch issue
  • smart value condition: This will check if the issue was created more than 1 minute ago.
    • first value: {{issue.created.diff(now).minutes}}
    • condition: greater than
    • second value: 1
  • JQL condition to check the clone does not exist
  • action: clone the issue

You may adjust that 1 minute to meet your needs / risk tolerance.  (For example, if there is an Atlassian automation outage and all rules stop running, theoretically the problem could still happen when the rules try to "catch up" running later.)

 

Like Alex Dokhtiar likes this
Alex Dokhtiar November 12, 2024

It works!

I considered checking the time difference since creation but didn’t think I could just use two separate rules.

Had to add re-fetch step for the creation rule, otherwise it didn't work. Also, I've used seconds instead of minutes to cover case with a quick transaction.

I will make a separate post with screenshots so I can accept the answer, unfortunately can't do so with you comment above.

Thank you a ton for helping me, Bill!

Like Bill Sheboy likes this
0 votes
Laura Pellizzari
Contributor
November 7, 2024

Hi, 

looking at this problem at the source. Why not restrict it to just the "open" status when creating the ticket?

 

 

regards

Laura

Alex Dokhtiar November 8, 2024

Hi Laura,

 

You are right, it can be done, but due to the nature of the workflow, tasks can be created in other statuses as well.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events