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

Importing a workflow with a transition that has a 'unconditional-result' XML element that references an Issue Status containing ampersand causes fatal Jira error

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Medium
    • None
    • 8.20.10
    • None

    Description

      When a user imports a workflow XML using Jira XML Restore or Jira Workflow import the Jira system can 'malfunction' after a successful import under the following condition:

      A workflow transition has an 'unconditional-result' element that references an Issue Status whose name contains an ampersand character.

      The ampersand character is special in XML and needs to be escaped differently than other characters. Per this stackoverflow article, we can escape ampersand using

      &
      

      If we were to import the workflow xml contain the correct rendered '&' with escape characters

          <action id="711" name="research">
            <meta name="jira.description"></meta>
            <meta name="jira.fieldscreen.id"></meta>
            <results>
              <unconditional-result old-status="common" status="Pending R&amp;amp;D" step="7">
                <post-functions>
                  <function type="class">
                    <arg name="class.name">com.atlassian.jira.workflow.function.issue.UpdateIssueStatusFunction</arg>
                  </function>
                  <function type="class">
                    <arg name="class.name">com.atlassian.jira.workflow.function.misc.CreateCommentFunction</arg>
                  </function>
                  <function type="class">
                    <arg name="class.name">com.atlassian.jira.workflow.function.issue.GenerateChangeHistoryFunction</arg>
                  </function>
                  <function type="class">
                    <arg name="class.name">com.atlassian.jira.workflow.function.issue.IssueReindexFunction</arg>
                  </function>
                  <function type="class">
                    <arg name="eventTypeId">13</arg>
                    <arg name="class.name">com.atlassian.jira.workflow.function.event.FireIssueEventFunction</arg>
                  </function>
                </post-functions>
              </unconditional-result>
            </results>
          </action>
      

      Jira will parse the workflow but store the above with

      "Pending R&amp;D"  
      

      instead of the original

      "Pending R&amp;amp;D" 
      

      and will have a problem parsing the stored workflow XML, which caused two severe problems:

      1) The Workflows page will be blank and log file will show a parsing error, for example

      Caused by: java.lang.RuntimeException: com.opensymphony.workflow.FactoryException: Error converting XML to workflow descriptor.: root cause: org.xml.sax.SAXParseException; lineNumber: 145; columnNumber: 70; The reference to entity "D" must end with the ';' delimiter.
          at com.atlassian.jira.workflow.CachingWorkflowDescriptorStore.loadWorkflowDescriptor(CachingWorkflowDescriptorStore.java:110)
          at com.atlassian.cache.memory.MemoryCacheManager$2.load(MemoryCacheManager.java:205)
          at com.atlassian.cache.memory.DelegatingCache.lambda$get$0(DelegatingCache.java:165)
          at com.atlassian.cache.memory.DelegatingCache.lambda$get$1(DelegatingCache.java:193)
          at com.google.common.cache.LocalCache$LocalManualCache$1.load(LocalCache.java:4868)
          at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2282)
          at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2159)
          at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2049)
          at com.google.common.cache.LocalCache.get(LocalCache.java:3966)
          at com.google.common.cache.LocalCache$LocalManualCache.get(LocalCache.java:4863)
          at com.atlassian.cache.memory.DelegatingCache.get(DelegatingCache.java:180)
          ... 477 more
      

      2) The Issue Statuses page will get an HTTP 500 error with the log file showing

      2023-07-06 00:43:54,108-0700 http-nio-42010-exec-5 ERROR admin 43x490x1 3uaeel 0:0:0:0:0:0:0:1 /secure/admin/ViewStatuses.jspa [o.a.c.c.C.[Catalina].[localhost].[/j82010]] Unhandled exception occurred whilst decorating page
      com.google.template.soy.tofu.SoyTofuException: In 'foreach' command \{foreach $status in $statuses}
      
      {call .statusRow}\{param status: $status /}{param first: isFirst($status) /}\{param last: isLast($status) /}{param token: $token /}\{/call}{/foreach}, the data reference does not resolve to a SoyList (encountered type com.google.template.soy.data.restricted.UndefinedData).
              at JIRA.Templates.Statuses.success(Unknown Source)
              at com.google.template.soy.tofu.internal.BaseTofu.renderMainHelper(BaseTofu.java:369)
      ...
      Caused by: com.google.template.soy.sharedpasses.render.RenderException: In 'foreach' command \{foreach $status in $statuses}{call .statusRow}
      {param status: $status /}
      {param first: isFirst($status) /}
      {param last: isLast($status) /}
      {param token: $token /}
      {/call}
      {/foreach}
      
      , the data reference does not resolve to a SoyList (encountered type com.google.template.soy.data.restricted.UndefinedData).
              at JIRA.Templates.Statuses.success(Unknown Source)
              at com.google.template.soy.sharedpasses.render.RenderVisitor.visitForeachNode(RenderVisitor.java:387)
              at com.google.template.soy.soytree.AbstractSoyNodeVisitor.visit(AbstractSoyNodeVisitor.java:104)
      

      The problem can occur in two ways

      • restoring a Jira XML backup containing the problematic workflow
      • importing the problematic workflow's xml

      The problem was originally reported by a user who restored a Jira Cloud XML backup to a DC instance with an Issue Status of 'Pending R&D' and a few workflows reference it in the transitions.

      The workaround for the user was to change the Issue Status name to avoid using an ampersand sign.  The workaround in the reproducer scenario (importing the problematic workflow) is to delete the workflow from jiraworkflows table.

      I have a reproducer workflow XML file and video recording demonstrating the symptoms described above.  I am using version 8.20.10 for the reproducer, but I think the problem likely exists in later Jira versions:

      • reproducer-ampersand-workflow-transition.mov (demo import workflow and watch Workflows and Issue Statuses pages fail)
      • test-ampersand-break.xml (workflow xml)

      Attachments

        Activity

          People

            Unassigned Unassigned
            f69110b8fa9f Johnny Mon
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated: