Approval fails to start in specific workflow if the definition has any condition applied to it
Description
In specific circumstances, the approval started through a workflow action fails.
Steps to reproduce:
-
Create a condition that will be true in your scenario
-
specifics do not matter here, the expression can even be simple ”true”)
-
-
Create definition 0 (it’s needed to trigger status change with automation step)
-
any steps inside (e.g. User Step - Approval)
-
one success step - automation - status change to STATUS A
-
-
Create definition 1
-
any steps inside
-
apply a condition from point 1 here (to definition itself, not its steps)
-
-
Create a Jira workflow with these specifics:
-
there is a transition to STATUS A which performs “Start approval” action pointed to definition 1
-
-
Save the workflow
-
Open a work item that uses this workflow
-
Ensure that the item can be transitioned to STATUS A from current status
-
Start an approval manually using definition 0
-
Complete the approval so it triggers automation step on success
-
Wait for the status to change (optionally, refresh the page)
-
Notice that the status changed but a new approval based on definition 1 have not started
-
Go to AP global view → Instance errors and notice 2 new errors triggered
Notes/observations:
-
The issue does not occur if the status was changed by the user manually (timestamp 1:55 on the video).
-
The same workflow works without issues if the definition 1 does not have any condition applied (timestamp 2:20 on the video).
-
The errors from Instance errors page:
Jira expression can't be evaluated, user(id: 712020:dc84258b-338e-4954-bb98-dc7c10e418dd) doesn't have enough permissions.Details:Log ID: 238102Request body: ExpressionVerificationRequest[expression=true, callerOrigin=CURRENT_USER, userId=null, fieldId=null, customizedFailMassage=, referenceId=12473, definitionId=525174]
Approval based on definition name: 'WORKFLOW - definition 1 (with a condition)', id: 525589 could not be created, Jira expression can't be evaluated, user(id: {}) doesn't have enough permissions.Details:Log ID: 238103ovh.atlasinc.guarana.ModelException: Approval based on definition name: 'WORKFLOW - definition 1 (with a condition)', id: 525589 could not be created, Jira expression can't be evaluated, user(id: {}) doesn't have enough permissions.
-
Based on the above observations, possible cause seem to be insufficient permissions of Approval Path for Jira technical user to read conditions when starting an approval.
Change
-
When Approval Path itself moves a work item (an automation "Change status" step) and that workflow transition runs an Approval Path action, the app now uses its own access for that account, as it already did for Automation for Jira. Definition and step conditions evaluated as Current User run, so the approval starts.
Decisions
-
The app's own account is recognised by the account ids configured per environment. Other apps' bot accounts are not covered.
-
Current User conditions on such a start are evaluated with the app's access. To evaluate them as a person, set the action's user to "Selected user" or "User from work item field".
-
A failed action triggered by the app itself is listed in Instance errors. No notification is sent to the app account.
Fixes included
-
"Archive all approvals" and "Delete all approvals" actions triggered by the app's own status change now run with the app's access.
-
Failed workflow and automation actions triggered by the app itself or without a user are listed in Instance errors instead of being skipped. No notification is sent for them, nor for actions triggered by Automation for Jira.
-
Approvals started by the app no longer try the app account first when they read or write the work item property.
-
Conditions evaluated as a work item field user (for example Reporter) use the app's access when the field holds Automation for Jira or the app's own account. This covers work items created by an Automation rule; before, such a condition failed and the approval did not start.
Manual tester notes
-
Create definition A with an approval step and a success step "Change status" to status X. Create definition B with a definition condition (expression true, Current User).
-
In the workflow, add the "Start approval" action with definition B to the transition into X.
-
Start A on a work item and approve it: the status changes to X and an approval from B starts on its own (refresh the page).
-
Change B's condition expression to false and repeat: no approval starts, and Instance errors lists "could not be created, start condition was rejected".
-
Replace the action with "Archive all approvals" and repeat: the approvals on the work item are archived after the automatic status change.
-
Create a work item with an Automation rule, so its Reporter is Automation for Jira. Start a definition whose condition is evaluated as "Work item field User" with Reporter (expression true): the approval starts.
Before release
-
Check that addon.jiraTechnicalUserAccountIds in application.properties (prod) and application-qa.properties hold the account the app acts as. The prod 712020:dc84258b-338e-4954-bb98-dc7c10e418dd matches the account in this ticket's error.