Uploaded image for project: 'Migration Platform'
  1. Migration Platform
  2. MIG-359

Lack of parent/sub-task validation in CSV import causes invalid state

    XMLWordPrintable

Details

    • 76
    • Severity 2 - Major
    • 13

    Description

      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:

      1. 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
      2. 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)
      3. 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

      1. 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:

      1. Delete the broken issues
      2. Fix the CSV to have sub-tasks with only a single parent, no sub-tasks as parent
      3. Import it again

      OR

      1. Move the child issue to the incorrect parent issue and move it back to the correct parent issue.

      Or Contact Atlassian Support

      Attachments

        1. image-2022-12-23-15-08-42-149.png
          image-2022-12-23-15-08-42-149.png
          291 kB
        2. problem1.csv
          0.1 kB
        3. problem2.csv
          0.1 kB
        4. problem3.csv
          0.1 kB
        5. screenshot-1.png
          screenshot-1.png
          285 kB

        Issue Links

          Activity

            People

              Unassigned Unassigned
              jsilveira Jaime S
              Votes:
              8 Vote for this issue
              Watchers:
              47 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: