Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Unable to render content due to system error: Mail Handler

Nombulelo Zizi July 17, 2020

Good day,

 

We have this error on the logs when issues are created via mail handle. Some issues are created successfully and some throw this error " [c.a.renderer.v2.V2Renderer] Unable to render content due to system error: There is no ID mapped for the user key ''
java.lang.IllegalStateException: There is no ID mapped for the user key ''

 

The scrip we use on the mail handler

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.service.util.ServiceUtils
import com.atlassian.jira.service.util.handler.MessageUserProcessor
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.user.util.UserManager
import com.atlassian.mail.MailUtils
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.Issue

import javax.mail.Address
import javax.mail.Message
import javax.mail.internet.InternetAddress

def userManager = ComponentAccessor.getComponent(UserManager)
def projectManager = ComponentAccessor.getProjectManager()
def issueFactory = ComponentAccessor.getIssueFactory()
def messageUserProcessor = ComponentAccessor.getComponent(MessageUserProcessor)


def subject = message.getSubject() as String
log.error("Subject: " + subject)
def sender = MailUtils.getSenders(message)

log.error("sender: " + sender)

def addresses = message.getRecipients(Message.RecipientType.CC) as List<Address>
log.error("CC: " +addresses)


def issue = ServiceUtils.findIssueObjectInString(subject)


log.error("Issue: " + issue)

if (issue) {
return
}

 

if(sender.toString().contains("soctickets@mitigate.co.za"))
{
if(subject.toString().contains("Severity 1")
|| subject.toString().contains("Severity 2"))
{

ApplicationUser user = userManager.getUserByName("socreplies")
log.error("User: "+user)

log.error("Author: " + messageUserProcessor.getAuthorFromSender(message))
ApplicationUser reporteruser = messageUserProcessor.getAuthorFromSender(message) ?: user
log.error("reporteruser: "+reporteruser)
def project = projectManager.getProjectObjByKey("SD")
log.error("project: "+project)


def issueObject = issueFactory.getIssue()
log.error("issueObject request: " +issueObject)
issueObject.setProjectObject(project)

log.error("Project request: " +issueObject.setProjectObject(project))
issueObject.setSummary(subject)

log.error("Summary request: "+issueObject.setSummary(subject))
issueObject.setDescription(MailUtils.getBody(message))
issueObject.setIssueTypeId(project.issueTypes.find { it.name == "Incident" }.id)
log.error("Issue type request: " +issueObject.setIssueTypeId(project.issueTypes.find { it.name == "Incident" }.id))
issueObject.setReporter(reporteruser)
log.error("Reporter request: " + issueObject.setReporter(reporteruser))

def customFieldManager = ComponentAccessor.customFieldManager
def optionsManager = ComponentAccessor.optionsManager
def mySelectCf = customFieldManager.getCustomFieldObject('customfield_14146')
log.error("Field name: "+ mySelectCf)
def mySelectContextConfig = mySelectCf.getRelevantConfig(issueObject)
def selectOptions = optionsManager.getOptions(mySelectContextConfig)

def myOption = selectOptions.find{it.value == 'Mitigate'}
log.error("Ticket source value: " + myOption)

if(myOption){
log.error("Ticket source value is set")
issueObject.setCustomFieldValue(mySelectCf, myOption)
}
else
{
log.error("Ticket source value is not set")
}

try
{

messageHandlerContext.createIssue(userManager.getUserByName("socreplies"), issueObject)
log.error("Issue created")
}
catch(Exception e)
{
log.error("issue not created successfully due to error")
log.error(e)

}

}
else
{
log.error("Issue not created since it doesn't meet requirements")
}

}

 

 

Below is the logs of an issue that is created and an issue the is giving issues

 

 

********created sucessfully**********
2020-07-16 12:43:00,718+0200 Caesium-1-2 ERROR anonymous SOC Mail Handler [c.o.scriptrunner.runner.ScriptBindingsManager] Subject: [RT MMH #445460] Site: MMH - New Incident: Severity 1 - Firewall Configuration Changes
2020-07-16 12:43:00,719+0200 Caesium-1-2 ERROR anonymous SOC Mail Handler [c.o.scriptrunner.runner.ScriptBindingsManager] sender: [soctickets@mitigate.co.za]
2020-07-16 12:43:00,719+0200 Caesium-1-2 ERROR anonymous SOC Mail Handler [c.o.scriptrunner.runner.ScriptBindingsManager] CC: [MMISiem@mmltd.co.za, tickets@mitigate.co.za]
2020-07-16 12:43:00,719+0200 Caesium-1-2 ERROR anonymous SOC Mail Handler [c.o.scriptrunner.runner.ScriptBindingsManager] Issue: null
2020-07-16 12:43:00,719+0200 Caesium-1-2 ERROR anonymous SOC Mail Handler [c.o.scriptrunner.runner.ScriptBindingsManager] User: socreplies(JIRAUSER73506)
2020-07-16 12:43:00,725+0200 Caesium-1-2 ERROR anonymous SOC Mail Handler [c.o.scriptrunner.runner.ScriptBindingsManager] Author: null
2020-07-16 12:43:00,730+0200 Caesium-1-2 ERROR anonymous SOC Mail Handler [c.o.scriptrunner.runner.ScriptBindingsManager] reporteruser: socreplies(JIRAUSER73506)
2020-07-16 12:43:00,730+0200 Caesium-1-2 ERROR anonymous SOC Mail Handler [c.o.scriptrunner.runner.ScriptBindingsManager] project: Project: SD
2020-07-16 12:43:00,730+0200 Caesium-1-2 ERROR anonymous SOC Mail Handler [c.o.scriptrunner.runner.ScriptBindingsManager] issueObject request: null
2020-07-16 12:43:00,730+0200 Caesium-1-2 ERROR anonymous SOC Mail Handler [c.o.scriptrunner.runner.ScriptBindingsManager] Project request: null
2020-07-16 12:43:00,730+0200 Caesium-1-2 ERROR anonymous SOC Mail Handler [c.o.scriptrunner.runner.ScriptBindingsManager] Summary request: null
2020-07-16 12:43:00,778+0200 Caesium-1-2 ERROR anonymous SOC Mail Handler [c.o.scriptrunner.runner.ScriptBindingsManager] Issue type request: null
2020-07-16 12:43:00,778+0200 Caesium-1-2 ERROR anonymous SOC Mail Handler [c.o.scriptrunner.runner.ScriptBindingsManager] Reporter request: null
2020-07-16 12:43:00,778+0200 Caesium-1-2 ERROR anonymous SOC Mail Handler [c.o.scriptrunner.runner.ScriptBindingsManager] Field name: Ticket Source
2020-07-16 12:43:00,778+0200 Caesium-1-2 ERROR anonymous SOC Mail Handler [c.o.scriptrunner.runner.ScriptBindingsManager] Ticket source value: Mitigate
2020-07-16 12:43:00,778+0200 Caesium-1-2 ERROR anonymous SOC Mail Handler [c.o.scriptrunner.runner.ScriptBindingsManager] Ticket source value is set
2020-07-16 12:43:04,010+0200 Caesium-1-2 INFO anonymous SOC Mail Handler [c.a.j.p.webhooks.matcher.JqlEventMatcher_SLOW]
JQL query '{assignee in ("arweyers", "mmeyer", "musalie")} AND {reporter in ("arweyers", "mmeyer", "musalie")} AND
{project in ("I&O Work Management", "I&O Service Desk", "Change Management")} AND {project != "Problem Management"} AND {status != "Closed"} AND
{status != "Resolved"} AND {key in ("SD-405783")}' produced lucene query and took '85' ms to run.
2020-07-16 12:43:04,935+0200 Caesium-1-2 ERROR anonymous SOC Mail Handler [c.o.scriptrunner.runner.ScriptBindingsManager] Issue created

 

 

*******throws an error******************

2020-07-16 12:50:00,680+0200 Caesium-1-1 ERROR anonymous SOC Mail Handler [c.o.scriptrunner.runner.ScriptBindingsManager] Subject: [RT MMH #445469] Site: MMH - New Incident: Severity 2 - Suspicious Traffic
2020-07-16 12:50:00,682+0200 Caesium-1-1 ERROR anonymous SOC Mail Handler [c.o.scriptrunner.runner.ScriptBindingsManager] sender: [soctickets@mitigate.co.za]
2020-07-16 12:50:00,682+0200 Caesium-1-1 ERROR anonymous SOC Mail Handler [c.o.scriptrunner.runner.ScriptBindingsManager] CC: [MMISiem@mmltd.co.za, tickets@mitigate.co.za]
2020-07-16 12:50:00,682+0200 Caesium-1-1 ERROR anonymous SOC Mail Handler [c.o.scriptrunner.runner.ScriptBindingsManager] Issue: null
2020-07-16 12:50:00,682+0200 Caesium-1-1 ERROR anonymous SOC Mail Handler [c.o.scriptrunner.runner.ScriptBindingsManager] User: socreplies(JIRAUSER73506)
2020-07-16 12:50:00,695+0200 Caesium-1-1 ERROR anonymous SOC Mail Handler [c.o.scriptrunner.runner.ScriptBindingsManager] Author: null
2020-07-16 12:50:00,699+0200 Caesium-1-1 ERROR anonymous SOC Mail Handler [c.o.scriptrunner.runner.ScriptBindingsManager] reporteruser: socreplies(JIRAUSER73506)
2020-07-16 12:50:00,699+0200 Caesium-1-1 ERROR anonymous SOC Mail Handler [c.o.scriptrunner.runner.ScriptBindingsManager] project: Project: SD
2020-07-16 12:50:00,700+0200 Caesium-1-1 ERROR anonymous SOC Mail Handler [c.o.scriptrunner.runner.ScriptBindingsManager] issueObject request: null
2020-07-16 12:50:00,700+0200 Caesium-1-1 ERROR anonymous SOC Mail Handler [c.o.scriptrunner.runner.ScriptBindingsManager] Project request: null
2020-07-16 12:50:00,700+0200 Caesium-1-1 ERROR anonymous SOC Mail Handler [c.o.scriptrunner.runner.ScriptBindingsManager] Summary request: null
2020-07-16 12:50:00,717+0200 Caesium-1-1 ERROR anonymous SOC Mail Handler [c.o.scriptrunner.runner.ScriptBindingsManager] Issue type request: null
2020-07-16 12:50:00,717+0200 Caesium-1-1 ERROR anonymous SOC Mail Handler [c.o.scriptrunner.runner.ScriptBindingsManager] Reporter request: null
2020-07-16 12:50:00,717+0200 Caesium-1-1 ERROR anonymous SOC Mail Handler [c.o.scriptrunner.runner.ScriptBindingsManager] Field name: Ticket Source
2020-07-16 12:50:00,717+0200 Caesium-1-1 ERROR anonymous SOC Mail Handler [c.o.scriptrunner.runner.ScriptBindingsManager] Ticket source value: Mitigate
2020-07-16 12:50:00,717+0200 Caesium-1-1 ERROR anonymous SOC Mail Handler [c.o.scriptrunner.runner.ScriptBindingsManager] Ticket source value is set
2020-07-16 12:50:00,971+0200 Caesium-1-1 ERROR Anonymous user SOC Mail Handler [c.a.renderer.v2.V2Renderer] Unable to render content due to system error: There is no ID mapped for the user key ''
java.lang.IllegalStateException: There is no ID mapped for the user key ''

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events