Uploaded image for project: 'Jira Data Center'
  1. Jira Data Center
  2. JRASERVER-34729

Exception On Subtasks With out Sequences

    XMLWordPrintable

Details

    Description

      Issues that have subtasks that don't have a link sequence output an exception to the main U.I.

      "
      An error occurred whilst rendering this message. Please contact the administrators, and inform them of this bug. Details: ------- org.apache.velocity.exception.MethodInvocationException: Invocation of method 'getHtml' in class com.atlassian.jira.web.component.subtask.SubTaskReorderColumnLayoutItem threw exception java.lang.NullPointerException at templates/jira/issue/table/macros.vm[line 120, column 34] at org.apache.velocity.runtime.parser.node.ASTMethod.handleInvocationException(ASTMethod.java:337) at org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:284) at org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:262) at org.apache.velocity.runtime.parser.node.ASTReference.value(ASTReference.java:507) at org.apache.velocity.runtime.parser.node.ASTExpression.value(ASTExpression.java:71) at org.apache.velocity.runtime.parser.node.ASTSetDirective.render(ASTSetDirective.java:142) at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:72) at org.apache.velocity.runtime.directive.Foreach.performIteration(Foreach.java:393) at org.apache.velocity.runtime.directive.Foreach.render(Foreach.java:316) at org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:175) at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:72) at org.apache.velocity.runtime.directive.VelocimacroProxy.render(VelocimacroProxy.java:212) at org.apache.velocity.runtime.directive.RuntimeMacro.render(RuntimeMacro.java:247) at org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:175) at
      ...
      "

      One scenario where this occurred is that the Data was imported through the beta JSON importing interface, so I understand the desire, not to resolve this bug.

      However, shouldn't the behavior being when there is a subtask(via an issue link ) that if there isn't a sequence that a reorder be called (instead of outputting an exception) ?

      (I also created an issue, because I couldn't find anything on this error, so hopefully, this will help anyone who runs into this in the future. )

      Another possibility that this could happen is when performing migration from Jira Cloud to Jira on premises.

      Workaround:

      Option 1, Preferred - via the UI, safest as it doesn't involve any direct DB updates:

      1) Click on the triple dot menu on the right of a broken subtask:

      2) The actual referenced subtask will open, from there, click on 'More' button, select 'Move':

       

      3) Simply move this issue to another parent (it's self explanatory), then you can move it back to the original issue where the above exception was observed. Jira will handle the rest

      Option 2, Unsupported and risky as it involves direct DB updates which bypass the application logic, hence it can lead to further complications, you can also do it via direct DB update

      Please note, the information below is provided on a best effort, as-is basis as direct DB updates are risky and they also fall outside of Atlassian Support Offerings scope

      Should you still wish to go ahead with this, please practice the steps below in a test and staging environment first before implementing in production.
      Also, once ready to implement in production, please make sure to take native backups of Jira DB and perform the updates while Jira is down completely.
      Here are the steps:

      1) Firstly, identify if there are any issues with 'Null' value in sequence column in the issuelink table:

      select count(*) from issuelink where sequence IS NULL;
      

      If those records exist, identify all such issues:

      select * from issuelink where sequence IS NULL;
      

      2) Then update the sequence value from NULL to a number from 0 onwards (depending on how many subtasks are referenced by an affected issue):

      UPDATE issuelink SET sequence = 0 WHERE linktype=10100 and source=[source value of the issue you're fixing] AND sequence IS NULL;
      

      To elaborate, instead of Null - please put in a number starting from 0 and then incrementing it by 1 for every issue with the same 'source' value, for example, if you see source 10201 listed twice with 'null' value in sequence, you'd need to update the sequence on first record to 0, then on second to 1 etc, which means you'd need to write multiple SQL 'update' queries to fix affected issues one by one.

      If your DB support updates with subqueries, you can execute this update repeatedly until there are 0 records updated:

      /* REPEAT UNTIL 0 UPDATES */
      update issuelink set sequence = (select coalesce(max(il2.sequence) + 1, 0) from issuelink il2 where il2.source = source and il2.linktype = 10100)
      where id in (
      select id 
      from issuelink il
      where il.linktype = 10100 
      and il.sequence is null
      and il.source = source
      and il.destination = (select min(il2.destination) from issuelink il2 where il2.source = il.source and il2.linktype = 10100 and il2.sequence is null)
      );
      

      Or until there are no more results from the query below:

      select count(*) from issuelink where linktype = 10100 and sequence is null;
      

      Just replace 10100 by the subtask linktype id of your instance:

      select * from issuelinktype where linkname = 'jira_subtask_link';
      

      As Option 2 involves direct DB updates, it's best to engage your DBA to assist with implementing the workaround

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              95b5cdeba206 Michael Bostwick
              Votes:
              13 Vote for this issue
              Watchers:
              21 Start watching this issue

              Dates

                Created:
                Updated: