Json import may break issue history

XMLWordPrintable

    • 1
    • Severity 2 - Major

      Summary

      Affected version: (not available in field): 1000.1068.0

      JSON import allows you to import, among other data, issue history. However, it allows you to add issue history in a wrong format and after import it completely breaks the issue.

      We could see at least two problems:

      1. History with a null 'toString' and 'fromString'
      2. History with null 'fieldType'

      An example below for problem 1 (complete file available: problem1.json):

      "history": [
                              {
      				"items": [
                                      	{   
                                          	"field": "assignee",
                                          	"toString": null, 
                                          	"fieldType": "jira",
                                          	"fromString": null
                                      	}
                                  	],
                                  	"created": "2005-09-28T19:09:19Z",
                                  	"author": "unknown"
                              }
      ]
      

      We can see that 'toString' and 'fromString' are both null. This is not accepted in JIRA, but JSON import accepts it and the issue is imported/created but it contains a broken issue history.

      When accessing the issue, we can see this error in logs (an a pop-up window appears saying the issue has problems):

      2017-06-19 13:40:14.619705500 java.lang.IllegalStateException: You cannot create a change item without either a 'from' or 'to' value.
      2017-06-19 13:40:14.619706500 	at com.atlassian.jira.issue.history.ChangeItemBean$Builder.build(ChangeItemBean.java:327)
      2017-06-19 13:40:14.619747500 	at com.atlassian.jira.issue.changehistory.DefaultChangeHistoryManager.lambda$getChangeItemsForField$0(DefaultChangeHistoryManager.java:218)
      2017-06-19 13:40:14.619748500 	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
      2017-06-19 13:40:14.619748500 	at java.util.Iterator.forEachRemaining(Iterator.java:116)
      2017-06-19 13:40:14.619748500 	at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
      

      For problem 2:

       		    "history": [
                              {
      				"items": [
                                      	{   
                                          	"field": "assignee",
                                          	"toString": "unknown", 
                                          	"fieldType": null,
                                          	"fromString": null
                                      	}
                                  	],
                                  	"created": "2005-09-28T19:09:19Z",
                                  	"author": "unknown"
                              }
      			]
      
      

      Again, it's imported and when accessing it, we get this error (complete file available: problem2.json), again a message saying 'There were errors loading the issue.' in UI and sometimes we can't even open the issue:

      2017-06-19 13:48:17.057859500 2017-06-19 13:48:17,050 http-nio-3003-exec-8 ERROR      [o.a.c.c.C.[.[localhost].[/].[action]] Servlet.service() for servlet [action] in context with path [] threw exception [java.lang.IllegalStateException: You cannot create a change item without a field type.] with root cause
      2017-06-19 13:48:17.057862500 java.lang.IllegalStateException: You cannot create a change item without a field type.
      2017-06-19 13:48:17.057863500 	at com.atlassian.jira.issue.history.ChangeItemBean$Builder.build(ChangeItemBean.java:324)
      2017-06-19 13:48:17.057896500 	at com.atlassian.jira.issue.changehistory.DefaultChangeHistoryManager.lambda$getChangeItemsForField$0(DefaultChangeHistoryManager.java:218)
      2017-06-19 13:48:17.057897500 	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
      2017-06-19 13:48:17.057898500 	at java.util.Iterator.forEachRemaining(Iterator.java:116)
      2017-06-19 13:48:17.057898500 	at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
      2017-06-19 13:48:17.057905500 	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
      2017-06-19 13:48:17.057905500 	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
      2017-06-19 13:48:17.057906500 	at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
      2017-06-19 13:48:17.057913500 	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
      

      Steps to Reproduce

      1. Import JSON problem1.json or problem2.json
      2. Access issue created

      Expected Results

      • Issues are created without error
      • History items are correct

      Actual Results

      • Issues are created with broken history
      • We can see the errors in logs

      Workaround

      None so far

        1. problem2.json
          1 kB
        2. problem1.json
          1 kB

            Assignee:
            Ricardo Nakamura (Inactive)
            Reporter:
            Jaime S
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: