Problems caused by importing and using a Workflow with missed status in Jira
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
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
Please notice that this is not supported by Atlassian. It is provided for reference only and please make sure to make backups before applying the resolution below. Please refer Atlassian Support Offerings for more information.
Summary
When a Jira admin exports an XML from a Jira instance A and imports it to a target Jira instance B where some of the statuses are not available to be used in the imported workflow, Jira allows the import to proceed and marks the invalid status with a "?" at the workflow.
It may happen that a workflow scheme is created for this inconsistent workflow, and there is no validation to block this action. JRASERVER-43561 - Getting issue details... STATUS
If this workflow scheme is used by a project, it will cause multiple errors.
The goal of this document is to centralize information about the related bugs, feature requests, suggested workaround, and knowledge base articles related to this topic.
Environment
All Jira versions up to 8.12
Diagnosis
Steps to Reproduce:
1. On a staging instance of Jira create a new status;
2. Create a new workflow using the new status;
3. Export the workflow XML;
4. On production Jira import the workflow XML;
5. View the imported workflow using the "text" option. Observe that invalid status are marked with a "?" symbol;
6. Create a new workflow scheme and associate the invalid workflow imported;
7. Associate the new workflow scheme with a Project.
Problems observed:
Cause
The exported workflow contains the Status ID used by the step. This Status ID was created at the Source Environment, and the same ID may not exist, it may be already in use by another Status or the status may already exist, but with another ID. Some samples:
Source ID | Source Description | Target ID | Target Description | Action |
---|---|---|---|---|
10100 | To approval | 10500 | For approval | It could reuse the status as they have similar meanings |
10101 | Under Development | - | - | It needs to be created |
10105 | To test | 10100 | To test | It already exists, but with a different ID |
It is not possible for the Import Process, to find which would be the correct action to do for the Status, depending on manual adjustments.
Solution
We need to identify for each workflow step if the status used is correct, duplicated, or missing.
1. Review information from the Source Workflow:
- Edit the workflow XML imported using an external XML viewer of text editor
- For each step, identify the status (id and name), where:
<step id="3" name="The STEP name"> - Contains the name of the step
<meta name="jira.status.id">10007</meta> - Contains the ID of the status
<action id="41" name="The status name"> - Contains the transition action
- Identify the Categories used for each status ("To Do", "In Progress", "Done") at the Admin > Issues > Statuses page:
Status | Status ID | Category |
---|---|---|
Open | 1 | To Do |
In Progress | 10100 | In Progress |
Testing | 10200 | In Progress |
Closed | 6 | Done |
2. Review information from the Target workflow:
- Check all available Status at the Admin > Issues > Statuses page;
- Read the "ISSUESTATUS" table to get the ID of each status:
SELECT * FROM "ISSUESTATUS"
3. Identify the correct Status ID and required steps
This auxiliary table will help to understand the required actions to adjust the Status ID at the Target environment:
Source Status | Source Status ID | Source Category | Target Status | Target Status ID | Target Category | Required actions to fix |
---|---|---|---|---|---|---|
Open | 1 | To Do | Open | 1 | To Do | |
In Progress | 10100 | In Progress | In Progress | 3 | In Progress | Update Status ID to 3 from 10100 |
Testing | 10200 | In Progress | - | - | - | Create a new status |
Closed | 6 | Done | Closed | 6 | Done |
4. Create each missed status:
- Reach Admin > Issues > Statuses;
- Click the button "Add Status";
- Insert the missed Status and select the category;
Identify the new Status ID created running the following query, replacing xxx with the inserted status:
SELECT * FROM issuestatus where pname = 'xxx';
Source Status | Source Status ID | Source Category | Target Status | Target Status ID | Target Category | Required actions to fix |
---|---|---|---|---|---|---|
Open | 1 | To Do | Open | 1 | To Do | |
In Progress | 10100 | In Progress | In Progress | 3 | In Progress | Update Status ID to 3 from 10100 |
Testing | 10200 | In Progress | Testing | 10100 | In Progress | Update Status ID to 10100 from 10200 |
Closed | 6 | Done | Closed | 6 | Done |
5. Update Workflow with the correct Status ID
- At the target environment, search for the imported workflow, where "MyScrum" is the workflow name
SELECT * FROM jiraworkflows where workflowname = 'MyScrum'
- Extract the descriptor column using CSV format and the Workflow ID returned by the previous query:
Copy (SELECT descriptor FROM jiraworkflows WHERE id = 10300) to '/tmp/desc.csv' DELIMITER ',' QUOTE '''' CSV;
- Using an XML Editor, change the Status to the correct Status ID:
Copy the full XML and update the workflow with the changed descriptor
UPDATE jiraworkflows SET descriptor = '<paste here the full edited descriptor>' where workflowname = 'MyScrum';
In some Oracle Databases, the above Update query will fail if the descriptor value is >4000 characters, which it usually is. To work around this, the descriptor value should be split into smaller strings and concatenated according to the clob format, like this:
update jiraworkflows set descriptor = ( to_clob( 'part 1 of xml' ) || to_clob( 'part 2 of xml' )) where workflowname = 'MyScrum';
6. Restart Jira Servers to refresh caches
After the changes, restart your JIRA Instance. For JIRA Data Center, a rolling restart was found sufficient to clean up all caches used to store Workflow configuration.
7. Recreate all affected Boards
All Boards using the impacted Project Area or using a filter that does not have "Project" at the filter clause will remain impacted.
Recreating the board with the same filter addresses the problem.
8. Agile Reports
There will be Scope changes due to the invalid status:
Before changing the workflow: | After fixing the invalid workflow: |
Additional information
Related articles
NullPointerException after importing workflow XML
Unable to utilize imported or restored workflow in Jira server
Jira Errors due to non-existing status
Fixing Workflows with Duplicate occurrence of action
Removing Workflow Step Fails with No status with that ID could be found, it may have been deleted
A useful groovy script to check all workflows for steps with an invalid status
/**
* Groovy script to check all workflows for steps with an invalid status
* Courtesy of @Matt Doar
*/
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.workflow.JiraWorkflow;
import com.atlassian.jira.config.StatusManager
/**
* Check all workflows have a valid status for each step.
* Jira doesn't check this when importing workflow XML.
*/
result = new StringBuffer()
def wfm = ComponentAccessor.getWorkflowManager()
def statusManager = ComponentAccessor.getComponent(StatusManager.class)
for (workflow in wfm.getWorkflows())
{
for (step in workflow.getDescriptor().getSteps())
{
statusId = step.getMetaAttributes().get(JiraWorkflow.STEP_STATUS_KEY)
status = statusManager.getStatus(statusId)
if (status == null) {
result.append("ERROR " + workflow.name + "<br/>")
}
}
}
return result.toString()
Note:
This groovy script relates to customizations in JIRA Applications and it requires a third party plugin (Adaptavist ScriptRunner). Consequently, Atlassian Support cannot guarantee the provision of any support for the code as customizations are not covered under Atlassian Support Offerings. Please be aware that this material is provided for your information only and that you use it at your own risk.