Subtask synchronization problem

During the simultaneous automatic creation of an issue and its sub-task by a script, followed immediately by synchronization via Exalate, it returns the error:

“While trying to create an issue of type ‘Sub-task’ in project ‘ITSUP’ for remote ‘ITSUPPORT-133474’, Jira responded with: Field Issue type is a sub-task but parent issue key or id not specified.: issuetype.”

But when I synchronize the sub-tasks separately, no error occurs.

if (firstSync) {

if(replica.parentId) {
def localParent = nodeHelper.getLocalIssueFromRemoteId(replica.parentId.toLong())

if(localParent) {
    issue.parentId  = localParent.id
}

}
}

The error you’re encountering:

“Field Issue type is a sub-task but parent issue key or id not specified.: issuetype”

Occurs because, at the time of the first synchronization, the parent issue is not yet available on the local instance. As a result, Exalate is unable to link the sub-task correctly under its parent, and Exalate prevents the creation of the sub-task without a defined parent.

This happens because both the issue and its sub-task are being created simultaneously, and there’s a brief moment where the parent issue does not yet exist locally when the sub-task tries to sync.

To address this, you have a few options:

  1. Ensure the parent issue is synchronized first
    Exalate should process the parent first, and if by the moment the sub-task is created the parent has not been created, it’s possible there’s another issue preventing the parent from syncing. Please check the configuration or any other errors affecting the parent’s creation.

  2. Add a safeguard in the Exalate script
    You can modify your script to stop the sub-task sync gracefully if the parent is not yet present. For example, using a return statement when the local parent cannot be found:

     if (firstSync && replica.parentId) {
         issue.typeName = "Sub-task"
         def localParent = nodeHelper.getLocalIssueFromRemoteId(replica.parentId.toLong())
         if (localParent) {
             issue.parentId = localParent.id
         } else {
             // Skip sync and wait until parent is available
             return
         }
     }
    
  3. Handle the error manually
    If this error occurs, you can go to the error, use the option “ignore related sync”, make sure the parent issue is synchronized, and then retry syncing the sub-task. Once the parent is present, the sub-task will sync successfully.

1 Like