Issue summary
If an incoming mail is used to add a comment to an existing ticket, this mail fails to be processed by the Service Desk Mail Handler if it has an attachment of size bigger than 10 MB with the error:
Unexpected error while running action as user...
Steps to replicate
- Install Jira 8.13.0 with JSD 4.13.0
- Create a new Service Desk project
- Configure a mail handler in the JSD project in Project Settings > Email Requests
- Create a new request in the JSD project via the customer portal
- Now, send a new email to the JSD Mail Handler by making sure:
- To include the issue key of the request created earlier in the subject (so that a new comment can be added to the existing request)
- That the sender of this email is the same as the reporter of the request created earlier (so that this user has the right to add a comment to this request)
- To include an attachment of size greater than 10 MB
- Wait for about 5 minutes for the Mail Handler to process this email (due to the large size of the email)
Actual Results
- Go to the JSD Email Request Audit Log, and observe that the mail failed to be processed with the following error:
- Check the Jira incoming mail logs, and observe the following error:
2020-11-26 11:06:18,638+0100 ERROR [] Caesium-1-3 anonymous Exception when MailHandlerWorker handles message:
java.lang.RuntimeException: Unexpected error while running action as user 'julien'
at com.atlassian.pocketknife.internal.util.runner.AuthenticationContextUtilImpl.runAs(AuthenticationContextUtilImpl.java:57) [?:?]
at com.atlassian.servicedesk.internal.feature.emailchannel.IncomingEmailServiceImpl.inEmailContext(IncomingEmailServiceImpl.java:504) [?:?]
at com.atlassian.servicedesk.internal.feature.emailchannel.IncomingEmailServiceImpl.lambda$doCreateNewOrCommentOnIssueWithMailChannel$15(IncomingEmailServiceImpl.java:185) [?:?]
...
Caused by: java.lang.IllegalArgumentException: Cannot format given Object as a Number
at java.text.NumberFormat.format(NumberFormat.java:248) [?:1.8.0_121]
at java.text.Format.format(Format.java:157) [?:1.8.0_121]
at java.text.MessageFormat.subformat(MessageFormat.java:1262) [?:1.8.0_121]
at java.text.MessageFormat.format(MessageFormat.java:865) [?:1.8.0_121]
at java.text.Format.format(Format.java:157) [?:1.8.0_121]
at com.atlassian.jira.i18n.BackingI18n.formatI18nMsg(BackingI18n.java:251) [classes/:?]
at com.atlassian.jira.i18n.BackingI18n.getText(BackingI18n.java:159) [classes/:?]
at com.atlassian.servicedesk.internal.comment.InternalServiceDeskCommentErrors.buildDisplayedAttachmentBlockWithParam(InternalServiceDeskCommentErrors.java:167) [?:?]
at com.atlassian.servicedesk.internal.comment.InternalServiceDeskCommentErrors.getAttachmentFailedMessages(InternalServiceDeskCommentErrors.java:144) [?:?]
at com.atlassian.servicedesk.internal.comment.AttachmentValidatorImpl.validateMailAttachmentsToAdd(AttachmentValidatorImpl.java:233) [?:?]
Expected results
A comment should be added
- with the attachment if the attachment size is less than 10MB
- without the attachment if the attachment size is more than 10MB
Note
The error is not replicated when sending an email to create a new issue (instead of sending an email to add a comment to an existing issue). In such case, the request is successfully created, but without the attachment:
Environment
Jira 8.13.0
JSD 4.13.0
Workaround
The workaround consists in increasing the attachment size limit in the file <JIRA_HOME>/jira-config.properties, so that the mail handler can accept attachments of size bigger than the default coded limit 10MB.
Note that the unit is in bytes, therefore, to set the limit to 20MB for example, the value to be set is 20971520.
Detailed steps below to change the limit to 20MB for example:
- Edit the file <JIRA_HOME>/jira-config.properties as per this kb by adding the following parameter:
webwork.multipart.maxSize = 20971520
- Re-start Jira