After deleting the content of a local field that is synchronized with a mandatory remote field, the error persists, even when the local field is refilled

Hello,

I would like to report an issue that is blocking ticket synchronization in our project. Here’s how to reproduce the problem:

Steps to Reproduce:

  1. Establish synchronization between two tickets.
  2. Attempt to delete the content of a local field that is synchronized with a mandatory remote field.
  3. An error occurs, and the following logic is triggered.
  4. Try to refill the local field to resolve the issue.
  5. Instead of the synchronization returning to normal, the error persists indefinitely.

This issue is causing ongoing problems with synchronization.

Code Reference: I’ve included the relevant code from my project below to help with troubleshooting.

Note: In the CEP project, the description field is mandatory.


outgoing:

if (issue.project?.key == “CEP”) {
replica.“description” = issue.description
}else if (issue.project?.key == “CSI”) {
replica.“description” = issue.description
}

incoming:

if (replica.project?.key == “CEP”)
{
if (replica.description == null) {
return
}
issue.customFields.“Description service SI”.value = replica.“description”
}else if (replica.project?.key == “CSI”)
{
if (replica.customFields.“Description service SI” == null) {
return
}
issue.description = replica.customFields.“Description service SI”?.value
}

This the error :

Impact: ISSUELocal entity: CEP-19397Remote entity: CSI-306Connection: CEP-_to_CSI_demandes de servicesError type: Update issue errorError Creation Time: Sep 17, 2024 16:10:04Error Detail Message: Could not update issue CEP-19397 with id 32277: Field description: Description est obligatoire… Check the documentation for more details.Error Stack Trace: jcloudnode.services.jcloud.exception.UpdateIssueJiraCloudException: Could not update issue CEP-19397 with id 32277: Field description: Description est obligatoire…
at jcloudnode.services.node.JCloudTrackerExceptionCategoryService.generateUpdateIssueJiraCloudTrackerException(JCloudTrackerExceptionCategoryService.scala:514)
at jcloudnode.services.jcloud.transport.JCloudClient.$anonfun$updateIssue$5(JCloudClient.scala:850)
at jcloudnode.services.jcloud.transport.JCloudRestErrorHandlingService$$anonfun$recoverFromRestExceptionToJiraCloudTrackerExceptionOrBugException$1.applyOrElse(JCloudRestErrorHandlingService.scala:238)
at jcloudnode.services.jcloud.transport.JCloudRestErrorHandlingService$$anonfun$recoverFromRestExceptionToJiraCloudTrackerExceptionOrBugException$1.applyOrElse(JCloudRestErrorHandlingService.scala:231)
at scala.concurrent.impl.Promise$Transformation.run(Promise.scala:490)
at akka.dispatch.BatchingExecutor$AbstractBatch.processBatch(BatchingExecutor.scala:63)
at akka.dispatch.BatchingExecutor$BlockableBatch.$anonfun$run$1(BatchingExecutor.scala:100)
at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
at scala.concurrent.BlockContext$.withBlockContext(BlockContext.scala:94)
at akka.dispatch.BatchingExecutor$BlockableBatch.run(BatchingExecutor.scala:100)
at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:49)
at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(ForkJoinExecutorConfigurator.scala:48)
at java.base/java.util.concurrent.ForkJoinTask.doExec(Unknown Source)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(Unknown Source)
at java.base/java.util.concurrent.ForkJoinPool.scan(Unknown Source)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(Unknown Source)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source)
Caused by: com.exalate.domain.exception.issuetracker.BadRequestTrackerRestException: Field description: Description est obligatoire…
at jcloudnode.services.jcloud.transport.JCloudRestErrorHandlingService$.handleTrackerFourZeroZeroAndHigherRestResponse(JCloudRestErrorHandlingService.scala:111)
at jcloudnode.services.jcloud.transport.JCloudRestErrorHandlingService$.filterTrackerRestErrorResponse(JCloudRestErrorHandlingService.scala:95)
at jcloudnode.services.jcloud.transport.JCloudClient.$anonfun$updateIssue$3(JCloudClient.scala:843)
at scala.concurrent.impl.Promise$Transformation.run(Promise.scala:470)
… 12 more
Incoming sync data: Summary: Ticket pour test CSI CEO synchro recetteEntity Key: CSI-306(id: 32275)Encoded payload: eyJ2ZXJzaW9uIjp7Im1ham9yIjoxLCJtaW5vciI6MTQsInBhdGNoIjowfSwiaHViSXNzdWUiOn

Based on your steps to reproduce and the code you provided, the problem seems to occur when the description field is deleted locally, and synchronization fails because the remote field is mandatory in the CEP project.

To address this, I recommend making the following adjustments to your outgoing and incoming scripts to handle empty or null fields more effectively:

Outgoing Script:

We can ensure that the local description field is only synchronized if it has a value:

if (issue.project?.key == "CEP" && issue.description != null) {
    replica."description" = issue.description
} else if (issue.project?.key == "CSI") {
    replica."description" = issue.description
}

This ensures that the description is only synced when it’s not null.

Incoming Script:

if (replica.project?.key == "CEP") {
    if (replica.description) {
        issue.customFields."Description service SI".value = replica."description"
    }
} else if (replica.project?.key == "CSI") {
    if (replica.customFields."Description service SI" != null) {
        issue.description = replica.customFields."Description service SI"?.value
    }
}

In this updated version:

  • Outgoing script: Only syncs the description field if it’s not null.
  • Incoming script: Skips updating the description if the remote value is empty or null, ensuring the sync doesn’t break.

Let me know if this resolves the issue, or if you need further assistance!