Service Management Email Request fails to process some attachments

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.

Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Problem

Service Management fails to process some email messages that contains multiple/larger attachments with the following error thrown in atlassian-jira.log

2018-04-09 16:45:42,238 Caesium-2-3 WARN sender@sender.com     [c.a.s.i.feature.emailchannel.IncomingEmailParser] Error processing email message
com.sun.mail.util.DecodingException: BASE64Decoder: Error in encoded stream: needed at least 2 valid base64 characters, but only got 0 before padding character (=), the 10 most recent characters were: "U5ErkJggg="
	at com.sun.mail.util.BASE64DecoderStream.decode(BASE64DecoderStream.java:271)
	at com.sun.mail.util.BASE64DecoderStream.read(BASE64DecoderStream.java:144)
	at java.io.FilterInputStream.read(FilterInputStream.java:107)
	at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1383)
	at org.apache.commons.io.IOUtils.copy(IOUtils.java:1357)
	at org.apache.commons.io.IOUtils.toByteArray(IOUtils.java:361)
	at com.atlassian.mail.MailUtils.buildAttachment(MailUtils.java:327)
	at com.atlassian.mail.MailUtils.addAttachments(MailUtils.java:302)
	at com.atlassian.mail.MailUtils.internalGetAttachments(MailUtils.java:289)
	at com.atlassian.mail.MailUtils.getAttachments(MailUtils.java:281)
	at com.atlassian.servicedesk.squalor.email.ServiceDeskMailUtils.getServiceDeskAttachments(ServiceDeskMailUtils.java:162)
	at com.atlassian.servicedesk.internal.feature.emailchannel.IncomingEmailParser.parse(IncomingEmailParser.java:66)
	at com.atlassian.servicedesk.internal.feature.emailchannel.IncomingEmailManagerImpl.lambda$createIssueInJiraContext$19(IncomingEmailManagerImpl.java:539)
	at com.atlassian.pocketknife.step.EitherStep1.lambda$then$0(EitherStep1.java:23)
	at io.atlassian.fugue.Either$RightProjection.flatMap(Either.java:886)
	at io.atlassian.fugue.Either.flatMap(Either.java:231)
	at com.atlassian.pocketknife.step.EitherStep1.then(EitherStep1.java:23)
	at com.atlassian.servicedesk.internal.feature.emailchannel.IncomingEmailManagerImpl.createIssueInJiraContext(IncomingEmailManagerImpl.java:539)
	at com.atlassian.servicedesk.internal.feature.emailchannel.IncomingEmailManagerImpl.createIssueFromEmail(IncomingEmailManagerImpl.java:219)
	at com.atlassian.servicedesk.internal.feature.emailchannel.IncomingEmailServiceImpl.createNewIssueWithRequestType(IncomingEmailServiceImpl.java:265)
	at com.atlassian.servicedesk.internal.feature.emailchannel.IncomingEmailServiceImpl.lambda$createNewIssueWithMailChannel$25(IncomingEmailServiceImpl.java:247)
	at io.atlassian.fugue.Either$RightProjection.flatMap(Either.java:886)

Diagnosis

Environment

  • Observed on Service Management 3.9.3 with QQMail (other versions/mail servers may be affected)
  • Email Request is setup using IMAP protocol

Diagnostic Steps

  • Verify whether the attachment is base64 encoded attachment is indeed corrupted. Obtain the original email message, then identify attachment with the string shown in the error message, ie: in the example log above
    "U5ErkJggg="
  • Copy the base64 encoded attachment data and try decoding it with any base64 decoder. If successful, the problem is not due incorrect base64 format in the original email itself.

Cause

Some mail servers do not work well with javamail's IMAP partial fetch (reason is unknown), as a result the email may only be fetched partially by Service Management which causes the base64 decoding error.

Workaround

Disable partial fetch by setting the JVM flags as per Setting Properties and Options on Startup

For IMAP protocol:

-Dmail.imap.partialfetch=false

For IMAP SECURE protocol:

-Dmail.imaps.partialfetch=false
Last modified on Nov 23, 2020

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.