Uploaded image for project: 'Jira Service Management Data Center'
  1. Jira Service Management Data Center
  2. JSDSERVER-6904

Some incoming mails containing attachment are processed but trigger an error in the Mail Audit Logs

    XMLWordPrintable

Details

    Description

      Issue Summary

      If an incoming mail meant to create a new Jira issue contains 2 attachments of exact name, the following will happen:

      • the Jira issue is successfully created and contains the 2 attachments (note that the filename of one attachment was modified by the mail handler with the extra "-1" at the end)
      • however, the Mail Processing logs from the page ⚙ > Applications > Email Requests show the error "Unexpected error while running action as user '"
      • also, the following error is thrown in the Jira application logs:
        2020-06-18 15:08:20,706+0200 Caesium-1-4 ERROR julien     [c.a.p.i.util.runner.AuthenticationContextUtilImpl] Unexpected error while running action as user 'julien'
        java.lang.IllegalStateException: Duplicate key com.atlassian.mail.MailUtils$Attachment@6e4443db
        	at java.util.stream.Collectors.lambda$throwingMerger$0(Collectors.java:133)
        	at java.util.HashMap.merge(HashMap.java:1253)
        	at java.util.stream.Collectors.lambda$toMap$58(Collectors.java:1320)
        	at java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169)
        	at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
        	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
        	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
        	at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
        	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        	at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
        	at com.atlassian.servicedesk.internal.feature.emailchannel.IncomingEmailManagerImpl.postProcessIssueCreation(IncomingEmailManagerImpl.java:773)
        	at com.atlassian.servicedesk.internal.feature.emailchannel.IncomingEmailManagerImpl.lambda$createIssueInJiraContext$22(IncomingEmailManagerImpl.java:554)
        	at com.atlassian.pocketknife.step.EitherStep4.lambda$null$0(EitherStep4.java:29)
        	at io.atlassian.fugue.Either$RightProjection.flatMap(Either.java:937)
        	at io.atlassian.fugue.Either.flatMap(Either.java:231)
        

      Steps to Reproduce

      • Install a fresh Service Desk 4.8.0 instance
      • Create a Service Desk project
      • Configure a Service Desk Mail handler in Project Settings > Email Requests
      • Send a new email to the mail handler, including 2 attachments of exact same name
        • Note that the 2 files don't need to have the same content. Only the filename matters to replicate the bug

      Expected Results

      A new ticket is created from this email and no error is thrown in the Mail Processing logs or Jira log file.

      Actual Results

      A new ticket is created from this email and an error is thrown in the Mail Processing logs or Jira log file.

      Workaround

      Workaround 1

      Remove any attachment with duplicate file name before sending an email to the Service Desk Mail Handler.

      Workaround 2

      Disable the dark feature sd.email.attachments.store.duplicates by:

      • Going to the page: <JIRA_BASE_URL>/secure/SiteDarkFeatures!default.jspa
      • Adding sd.email.attachments.store.duplicates.disabled to the list of dark features, as shown in the screenshot below:

      Important notes

      This bug is similar to the bug JSDSERVER-6884, however:

      • the steps to replicate it are different
      • the fix implemented for this bug is different than for the other one, therefore the fix version is different for both bugs
      • the workaround involving the dark feature only works for this bug, but not for the other one

      Attachments

        1. DarkFeature.png
          DarkFeature.png
          481 kB
        2. Bug_TicketCreated.png
          Bug_TicketCreated.png
          180 kB
        3. Bug_MailAuditLogs.png
          Bug_MailAuditLogs.png
          90 kB

        Issue Links

          Activity

            People

              ashubovych moofoo (Inactive)
              jrey Julien Rey
              Votes:
              2 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Backbone Issue Sync