I've just inherited a new instance of Jira Server, one of my users notified me that a job doesn't appear to have been running for a few weeks. Looking at the logs, I'm seeing the {reporter=The reporter specified is not a user.}, when I navigate to the issue(s) receiving the error, the reporter is an inactive user. I would expect this error on the creation of an issue, but not the update of an issue. We're currently running server version 8.2.4 and ScriptRunner Version 6.38.0. Below is the script that's producing the error. Any help would be appreciated.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.event.type.EventDispatchOption
// for all links of type "contains"
def linkManager = ComponentAccessor.getIssueLinkManager()
def links = linkManager.getOutwardLinks(issue.id)
.findAll { it.getLinkTypeId() == 10805}
.collect { it.getDestinationObject() }
if (links.size() == 0) return
// Custom fields to copy: "Requirements Document", "Design Memo", "FCCS", "SAS"
def requirementsDocumentField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(14110) as CustomField
def designMemoField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(14111) as CustomField
def FCCSField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(14112) as CustomField
def SASField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(14115) as CustomField
def cfList = [requirementsDocumentField, designMemoField, FCCSField, SASField]
if (links.size() > 1) {
// Return an error in the fields
for (field in cfList) {
field.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(field), 'Multiple issues linked as "contains"'), new DefaultIssueChangeHolder())
}
}
def issueService = ComponentAccessor.getIssueService()
def issueInputParams = issueService.newIssueInputParameters()
def user = ComponentAccessor.getJiraAuthenticationContext().loggedInUser
def linkedIssue = links[0] as com.atlassian.jira.issue.Issue;
for (field in cfList) {
issueInputParams.addCustomFieldValue(field.id, linkedIssue.getCustomFieldValue(field))
// Reversed direction for push from DE MSP -> DESI -> IPTs
//issueInputParameters.addCustomFieldValue(field.id, issue.getCustomFieldValue(field))
/* Update without writing to history
field.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(field), linkedIssue.getCustomFieldValue(field)), new DefaultIssueChangeHolder())
// Reversed direction for push from DE MSP -> DESI -> IPTs
//field.updateValue(null, linkedIssue, new ModifiedValue(linkedIssue.getCustomFieldValue(field), issue.getCustomFieldValue(field)), new DefaultIssueChangeHolder())
*/
}
def update = issueService.validateUpdate(user, issue.id, issueInputParameters)
// Reversed direction for push from DE MSP -> DESI -> IPTs
//def update = issueService.validateUpdate(user, linkedIssue.id, issueInputParameters)
issueService.update(user, update, com.atlassian.jira.event.type.EventDispatchOption.DO_NOT_DISPATCH, false);
Here's the full error:
2022-02-18 07:47:12,826 ERROR [jobs.EscalationService]: Escalation Service (Roll up Document Numbers from linked DESI issues) failed for issue DESI-3174
java.lang.Exception: Not attempting update. Errors: {reporter=The reporter specified is not a user.}
Error Messages: []
at com.onresolve.scriptrunner.canned.jira.utils.WorkflowUtil.updateIssue(WorkflowUtil.groovy:455)
at com.onresolve.scriptrunner.canned.jira.utils.WorkflowUtil.updateIssue(WorkflowUtil.groovy)
at com.onresolve.scriptrunner.canned.jira.utils.WorkflowUtil$updateIssue.call(Unknown Source)
at com.onresolve.scriptrunner.canned.jira.jobs.EscalationService$_execute_closure2$_closure5$_closure6.doCall(EscalationService.groovy:161)
at com.sun.proxy.$Proxy3261.accept(Unknown Source)
at java_util_function_Consumer$accept.call(Unknown Source)
at com.onresolve.jira.groovy.jql.AbstractPagerExecutor$_forEachInternal_closure2.doCall(AbstractPagerExecutor.groovy:68)
at com.onresolve.jira.groovy.jql.AbstractPagerExecutor.forEachInternal(AbstractPagerExecutor.groovy:67)
at com.onresolve.jira.groovy.jql.PagerExecutor.forEachIssue(PagerExecutor.groovy:26)
at com.onresolve.scriptrunner.canned.jira.jobs.EscalationService$_execute_closure2$_closure5.doCall(EscalationService.groovy:137)
at com.onresolve.scriptrunner.canned.jira.jobs.EscalationService$_execute_closure2$_closure5.doCall(EscalationService.groovy)
at com.onresolve.scriptrunner.jobs.JiraIdentitySwitchingService.switchIndentityAndExecuteInternal(JiraIdentitySwitchingService.groovy:45)
at com.onresolve.scriptrunner.jobs.JiraIdentitySwitchingService.executeAs(JiraIdentitySwitchingService.groovy:27)
at com.onresolve.scriptrunner.jobs.IdentitySwitchingService$executeAs.call(Unknown Source)
at com.onresolve.scriptrunner.canned.jira.jobs.EscalationService$_execute_closure2.doCall(EscalationService.groovy:135)
at com.onresolve.scriptrunner.canned.jira.jobs.EscalationService$_execute_closure2.doCall(EscalationService.groovy)
at com.onresolve.scriptrunner.runner.diag.DiagnosticsManagerImpl$DiagnosticsExecutionHandlerImpl$_execute_closure1.doCall(DiagnosticsManagerImpl.groovy:370)
at com.onresolve.scriptrunner.runner.diag.DiagnosticsManagerImpl$DiagnosticsExecutionHandlerImpl$_execute_closure1.doCall(DiagnosticsManagerImpl.groovy)
at com.onresolve.scriptrunner.runner.ScriptExecutionRecorder.withRecording(ScriptExecutionRecorder.groovy:13)
at com.onresolve.scriptrunner.runner.ScriptExecutionRecorder$withRecording.call(Unknown Source)
at com.onresolve.scriptrunner.runner.diag.DiagnosticsManagerImpl$DiagnosticsExecutionHandlerImpl.execute(DiagnosticsManagerImpl.groovy:368)
at com.onresolve.scriptrunner.runner.diag.DiagnosticsExecutionHandler$execute$2.call(Unknown Source)
at com.onresolve.scriptrunner.canned.jira.jobs.EscalationService.execute(EscalationService.groovy:133)
at com.onresolve.scriptrunner.canned.jira.jobs.EscalationService.execute(EscalationService.groovy)
I agree, it doesn't make much sense for the update to fail because the reporter is no longer active.
But looking at the script, I wonder how it ever worked.
I'm assuming this script is in the "Additional Actions" in an Escalation Job configuration? Is there a transition selected in the configuration? It's possible that action is what's throwing the error.
But what I see in the script is a variable "issueInputParams" defined on line 31, but then line 47 attempts to use "issueInputParameters" to run validate the update.
Here is a cleaned-up version of the script (with some groovyfication):
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.event.type.EventDispatchOption
// for all links of type "contains"
def linkManager = ComponentAccessor.issueLinkManager
def links = linkManager.getOutwardLinks(issue.id)
.findAll { it.getLinkTypeId() == 10805 }
.collect { it.getDestinationObject() }
if (links.size() == 0) return
// Custom fields to copy: "Requirements Document", "Design Memo", "FCCS", "SAS"
def cfIdList = [14110, 14111, 14112, 14115]
def cfList = cfIdList.collect { ComponentAccessor.customFieldManager.getCustomFieldObject(it as Long) }
if (links.size() > 1) {
// Return an error in the fields
cfList.each { field ->
def modifiedValue = new ModifiedValue(issue.getCustomFieldValue(field), 'Multiple issues linked as "contains"')
field.updateValue(null, issue, modifiedValue, new DefaultIssueChangeHolder())
}
}
def issueService = ComponentAccessor.issueService
def issueInputParams = issueService.newIssueInputParameters()
def user = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def linkedIssue = links[0] as Issue
cfList.each { field ->
issueInputParams.addCustomFieldValue(field.id, linkedIssue.getCustomFieldValue(field) as String)
// Reversed direction for push from DE MSP -> DESI -> IPTs
//issueInputParameters.addCustomFieldValue(field.id, issue.getCustomFieldValue(field))
/* Update without writing to history
field.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(field), linkedIssue.getCustomFieldValue(field)), new DefaultIssueChangeHolder())
// Reversed direction for push from DE MSP -> DESI -> IPTs
//field.updateValue(null, linkedIssue, new ModifiedValue(linkedIssue.getCustomFieldValue(field), issue.getCustomFieldValue(field)), new DefaultIssueChangeHolder())
*/
}
def updateValidationResult = issueService.validateUpdate(user, issue.id, issueInputParams)
// Reversed direction for push from DE MSP -> DESI -> IPTs
//def update = issueService.validateUpdate(user, linkedIssue.id, issueInputParameters)
if(updateValidationResult.isValid()) {
issueService.update(user, updateValidationResult, EventDispatchOption.DO_NOT_DISPATCH, false)
} else {
log.error "Validation results returned one or more errors: $updateValidationResult.errorCollection"
}
I also added a check for an error in the validation step so it can fail a bit more gracefully.
@PD Sheehan The issueInputParams vs issueInputParameters was my mistake, the original script used the latter (issueInputParameters) which is reserved I was in the process of updating that to issueInputParams when I posted this and hadn't finished that update.
You're assumption would be correct, this is an additional issue action, no transition is selected, its run based on a query every night at 12:30 am.
Tried running your script with the same error in the logs. :(
2022-02-21 14:48:55,372 ERROR [runner.ScriptBindingsManager]: Validation results returned one or more errors: Errors: {reporter=The reporter specified is not a user.}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That's an interesting validation that I wasn't aware could happen.
Then the next solution is retire the issueService for that script and instead user issueManager.updateIssue() followed by re-indexing step.
This will still give your the issue history.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.