Summary
When importing CSV to JIRA with parents and sub-tasks, (at least) 3 problems may happen depending on how the parent/sub-tasks are set, all due to no validation in the CSV file:
- If we import a sub-task (using the 'sub-task' Issue Type') without a parent, a sub-task will be created without a parent. (Example problem1.csv
) - This problem was already reported as an old bug from 2015, initially reported to Server: JRACLOUD-42405
- If we import 2 parents and set both of them as parents of a single sub-task, the sub-task will have 2 parents (Example problem2.csv
)
- If we import a sub-task having another sub-task as parent, it will have that sub-task as parent (Example problem3.csv
)
Identifying problems
We can check each problem and confirm them using the following queries:
Problem 1: Sub-tasks without parents:
select i.id as "child_id", ( p.pkey || '-' || i.issuenum ) as "child_key", it.pname as "child_type", it.pstyle as "child_type_style" from jiraissue i join project p on i.project = p.id join issuetype it on i.issuetype = it.id left join (select destination, source from issuelink where linktype in (select id from issuelinktype where linkname = 'jira_subtask_link') ) t on i.id = t.destination where it.pstyle = 'jira_subtask' and ( t.source not in (select id from jiraissue) or t.source is null) order by child_id desc;
child_id |
child_key |
child_type |
child_type_style |
10013 |
PCIT-12 |
Sub-task |
jira_subtask |
Problem 2: Issue with duplicate parents
select i.id as "child_id", ( p.pkey || '-' || i.issuenum ) as "child_key", it.pname as "child_type", it.pstyle as "child_type_style", t.count as "number_of_parents", parent_i.id as "parent_id", ( parent_p.pkey || '-' || parent_i.issuenum ) as "parent_key", parent_it.pname as "parent_type", parent_it.pstyle as "parent_type_style" from jiraissue i join project p on i.project = p.id join issuetype it on i.issuetype = it.id join (select destination, count(*) from issuelink where linktype= (select id from issuelinktype where linkname = 'jira_subtask_link') group by destination having count(*) > 1) t on i.id = t.destination join issuelink parent_l on i.id = parent_l.destination join jiraissue parent_i on parent_l.source = parent_i.id join project parent_p on parent_p.id = parent_i.project join issuetype parent_it on parent_i.issuetype = parent_it.id where parent_l.linktype in (select id from issuelinktype where linkname = 'jira_subtask_link') order by child_id desc;
child_id |
child_key |
child_type |
child_type_style |
number_of_parents |
parent_id |
parent_key |
parent_type |
parent_type_style |
10012 |
PCIT-11 |
Sub-task |
jira_subtask |
2 |
10010 |
PCIT-9 |
Task |
|
10012 |
PCIT-11 |
Sub-task |
jira_subtask |
2 |
10011 |
PCIT-10 |
Task |
|
Problem 3: Issues with sub-tasks as parents
select i.id as "child_id", ( p.pkey || '-' || i.issuenum ) as "child_key", it.pname as "child_type", it.pstyle as "child_type_style", parent_i.id as "parent_id", ( parent_p.pkey || '-' || parent_i.issuenum ) as "parent_key", parent_it.pname as "parent_type", parent_it.pstyle as "parent_type_style" from jiraissue i join project p on i.project = p.id join issuetype it on i.issuetype = it.id join issuelink il on i.id = il.destination join jiraissue parent_i on il.source = parent_i.id join project parent_p on parent_p.id = parent_i.project join issuetype parent_it on parent_i.issuetype = parent_it.id where il.linktype in (select id from issuelinktype where linkname = 'jira_subtask_link') and it.pstyle = 'jira_subtask' and parent_it.pstyle = 'jira_subtask'
child_id |
child_key |
child_type |
child_type_style |
parent_id |
parent_key |
parent_type |
parent_type_style |
10015 |
PCIT-14 |
Sub-task |
jira_subtask |
10014 |
PCIT-13 |
Sub-task |
jira_subtask |
Steps to Reproduce
- Import problem1.csv
or problem2.csv
or problem3.csv
Expected Results
Issue are not created, because they would create an invalid state in JIRA.
Actual Results
The issues are imported and invalid states mentioned above are created. Boards containing issues from problem 1 (and possible the others as well) break, generally showing a blank page.
Workaround
If possible:
- Delete the broken issues
- Fix the CSV to have sub-tasks with only a single parent, no sub-tasks as parent
- Import it again
OR
- Move the child issue to the incorrect parent issue and move it back to the correct parent issue.
Or Contact Atlassian Support