The JSM Mail Handler creates new tickets instead of adding comments to existing tickets due to invalid field context configuration

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

プラットフォームについて: Server および Data Center のみ。この記事は、Server および Data Center プラットフォームのアトラシアン製品にのみ適用されます。

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.

*Fisheye および Crucible は除く

    

要約

The Jira Service Management (JSM) Mail Handler creates a new ticket from any email reply instead of adding a comment to the ticket which was created from the original email.

The steps to replicate this issue are the following:

  • a fresh new email is sent to the email address configured in the Service Management Mail Handler (configured in Project Settings > Email Requests)
  • the Mail Handler creates a ticket from this new email
  • a user replies to that email (which was originally used to create a ticket)
  • the Mail Handler creates a new ticket instead of adding a comment to the existing ticket

(warning) Note that this knowledge article only applies to the Jira Service Management Mail Handler (which is configured in Project Settings > Email Requests within the Service Management project configuration page). This article does not apply to the Jira Mail handler (which is configured in ⚙ > System > Incoming email).

環境

Any Jira Service Management version from 3.0.0 and above.

診断

  • When checking the Processing Logs of the Mail Handler via the page ⚙ > Applications > JIRA Service Desk > Email Requests > View Log > Processing Log, we can see several occurrences of the error "Unexpected error while running action as user"
  • When checking the Jira Incoming Mail logs located in <Jira_Home>/log/atlassian-jira-incoming-mail.log, we can find occurrences of the following error:

    2022-02-12 13:04:14,622+0000 ERROR [] Caesium-1-4 anonymous     Exception when MailHandlerWorker handles message: 
    java.lang.RuntimeException: Unexpected error while running action as user 'XXXXXXXXXXXX'
    	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) [?:?]
    [...TRIMMED...]
    	at com.atlassian.servicedesk.internal.feature.emailchannel.IncomingEmailServiceImpl.createNewOrCommentOnIssueWithMailChannel(IncomingEmailServiceImpl.java:153) [?:?]
    	at com.atlassian.servicedesk.internal.feature.emailchannel.IncomingEmailServiceImpl.lambda$processEmailWithMailChannel$1(IncomingEmailServiceImpl.java:141) [?:?] 
    [...TRIMMED...]  
    at com.atlassian.servicedesk.internal.feature.emailchannel.IncomingEmailServiceImpl.processEmailWithMailChannel(IncomingEmailServiceImpl.java:141) [?:?]
    	at com.atlassian.servicedesk.internal.feature.emailchannel.emailplatform.handler.SDMailHandler.processMessage(SDMailHandler.java:75) [?:?]
    	at com.atlassian.servicedesk.internal.feature.emailchannel.emailplatform.handler.SDMailHandler.handleNewMessage(SDMailHandler.java:49) [?:?]
    	at com.atlassian.jira.internal.mail.processor.feature.processor.MailHandlerWorker.handle(MailHandlerWorker.java:62) [?:?]
    	at com.atlassian.jira.internal.mail.processor.feature.processor.MailProcessorWorker.processMailItem(MailProcessorWorker.java:121) [?:?]
    	at com.atlassian.jira.internal.mail.processor.feature.processor.MailProcessorWorker.lambda$process$0(MailProcessorWorker.java:96) [?:?]
    [...TRIMMED...]
        at com.atlassian.jira.internal.mail.processor.feature.processor.MailProcessorWorker.process(MailProcessorWorker.java:93) [?:?]
    	at com.atlassian.jira.internal.mail.processor.feature.processor.MailProcessorWorker.processAllValidMailChannels(MailProcessorWorker.java:143) [?:?]
    	at com.atlassian.jira.internal.mail.processor.feature.processor.MailProcessorService.run(MailProcessorService.java:25) [?:?]
    	at com.atlassian.jira.internal.mail.processor.services.MailProcessorExecutor.run(MailProcessorExecutor.java:29) [?:?]
    	at com.atlassian.jira.internal.mail.processor.services.AbstractMailExecutor.execute(AbstractMailExecutor.java:45) [?:?]
    	at com.atlassian.jira.internal.mail.processor.services.MailJobRunner.runJob(MailJobRunner.java:35) [?:?]
    	at com.atlassian.scheduler.core.JobLauncher.runJob(JobLauncher.java:134) [atlassian-scheduler-core-3.0.0.jar:?]
    [...TRIMMED...]
        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_202]
    Caused by: java.lang.NullPointerException
    	at com.atlassian.jira.issue.customfields.impl.SelectCFType.getDefaultValue(SelectCFType.java:223) [classes/:?]
    	at com.atlassian.servicedesk.internal.fields.optionsprovider.SelectOptionsProvider.getDefaultValues(SelectOptionsProvider.java:67) [?:?]
    	at com.atlassian.servicedesk.internal.fields.optionsprovider.SelectOptionsProvider.apply(SelectOptionsProvider.java:40) [?:?]
    	at com.atlassian.servicedesk.internal.fields.ServiceDeskJIRAFieldServiceImpl$OptionsProvidersFunction.lambda$apply$1(ServiceDeskJIRAFieldServiceImpl.java:366) [?:?]
    	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) [?:1.8.0_202]
    	at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175) [?:1.8.0_202]
    	at java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958) [?:1.8.0_202]
    
    ...
  • The request type which is linked to the Mail Handler (as per the configuration in Project Settings > Email Requests) is configured in the page Project Settings > Request Types > Edit Fields with a field which has an incorrect context configuration, meaning that:
    • either the context does not include the issue type associated with the impacted request type
    • or the context does not include the Service Management project request type configured in
  • The example below illustrates an example of incorrect context configuration:
    • The Mail Handler is configured with the Request Type IT help

    • The Request Type IT help is associated to the Issue Type IT Help, and is using the custom field called "Select List Test 2"
    • The field "Select List Test 2" is configured with a context that includes the issue type Bug, but is missing the issue type IT Help:

原因

Even though the symptoms in this KB article are different from the other KB article 500 error when trying to create a request from the Service Management Customer Portal, the underlying root cause is the same: there is a field in the Request Type configuration which has an incorrect context configuration. To ensure that the Mail Handler works as expected and creates issues/comments from incoming emails adequately, the field context needs to include both:

  • the Service Management project this request is configured in
  • and the issue type associated with the request type used by the Mail Handler

This issue is a side effect of the Service Management bug  JSDSERVER-7061 - Getting issue details... STATUS

You can find below some more details around why this Field Context Configuration is causing the Mail Handler to be unable to add comments to existing Jira issues:

  • When everything works as expected, the following happens:
    • when the Service Management Mail Handler processes a new email and creates a new issue (or adds a comment to an existing issue), it keeps track of the ID of the email it processed in the Database table notificationinstance.
      • That table will be populated with the mapping between Email IDs and Jira issue IDs, and the action done with the Jira issue (for example, the issue was created from the email, or a comment was added from the email)
    • If a user sends a reply to an email used to create an issue in the past and if no issue key is mentioned in the mail subject, the Service Desk Mail Handler scans the table notificationinstance to check if the original email was used to create a Jira issue:
      • if it detects that the original email was used to create an issue, then it will add a new comment to that issue
      • if it does not detect anything, it will create a new issue
  • When the mail handler is impacted by the problem described in this KB article, the following happens instead:
    • When a new email is sent, the mail handler creates a new Jira issue from it, but the creation process does not fully complete due to the error Unexpected error while running action as user
    • Because the issue creation does not complete properly, the mail handler fails to populate the table notificationinstance
    • Since the notificationinstance table is not populated properly:
      • the Mail Handler is not able to know if an email was a reply to an old email used to create a Jira issue
      • the Mail Handler keeps creating new Jira issues from email replies instead of adding comments to existing ones

ソリューション

Fix the Field Context Configuration of the problematic field, by following the resolution steps from the KB article from the other KB article 500 error when trying to create a request from the Service Management Customer Portal.

最終更新日: 2024 年 2 月 6 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.