Automation rule is triggered twice and fails with the error "Error marking step #XXXXX finished"
Platform Notice: Data Center - This article applies to Atlassian products on the Data Center platform.
Note that this knowledge base article was created for the Data Center version of the product. Data Center knowledge base articles for non-Data Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
An automation rule that is using the Transition Issue action is triggered twice and the error below is observed in the audit logs on the duplicate execution of this rule:
Error marking step #XXXXX finished: root cause: Tried to update an entity that does not exist
Environment
- Jira Server/Data Center on any version from 8.0.0
- Automation For Jira (A4J) Server/Data Center on any version from 7.4.0
Diagnosis
- The automation rule is configured with the Transition Issue action
- The trigger of the automation rule is Issue Transitioned, and it is configured with the option Execute this rule immediately ticked
- The transition that is executed by this automation rule is firing 2 events in its post-functions, which can be seen in the workflow configuration.
- The screenshot below shows an example of transition that is firing 2 events, the Generic Event, and the Issue Closed event:
- The screenshot below shows an example of transition that is firing 2 events, the Generic Event, and the Issue Closed event:
Cause
Automation rules are triggered on events that are fired from a specific Jira issue.
When using the workflow illustrated in the screenshot above, the following happens:
- 2 events are fired by the post-functions (the Generic Event and the Issue Closed Event)
- The automation rule is triggered twice (once per event, even though the issue that triggered the automation rule was transitioned only once)
- The 2nd time the automation rule is triggered, when the Transition Issue Action is executed by it, the error below is thrown in the audit logs because the rule is trying to transition the same issue a second time to "Done" (while it has already been done)
Error marking step #XXXXX finished: root cause: Tried to update an entity that does not exist
A few notes:
- The error is only replicable if the trigger of the rule is configured with the option Execute this rule immediately ticked
- Normally, it should not be possible to configure a transition to fire 2 events in Jira. However, under some conditions, a transition can be configured to fire a 2nd event, due to the bug below:
-
JSWSERVER-20014 - JIRA Agile Simplified Workflow allows you to add duplicates for some essential post functions Gathering Impact
-
Solution
Ensure that the transition only fires 1 event by removing one of the 2 post-functions that fires an event.