When I try to exalate a closed issue on Github I receive a "- 422 Validation Failed" error

Originally asked by Andres Martynowicz on 14 March 2022 (original question)


When I try to update Github Closed Issues from Jira, I receive an error “- 422 Validation Failed”. How do I solve this?


Answer by Andres Martynowicz on 14 March 2022

Github does not allow updating issues with status closed.

As a workaround, please use the following script on your Github Incoming Script:

import scala.Option
import com.exalate.services.utils.FutureUtils

if(issue.status.name.equalsIgnoreCase("closed")) {
    def none = Option.empty()
    def state = Option.apply("Open")
    def applyIssue = new services.node.values.ApplyIssue(none, issue.summary, none, none, none, state, none)
    
    def issue = FutureUtils.resultInf(nodeHelper.githubClient.updateIssue("{owner}/{repo}", Integer.valueOf(issue.key), applyIssue))
}

if(replica.status.name.equalsIgnoreCase("Done")) {
    issue.status = "Closed"
} else {
    issue.status = "Open"
}