During Transition of an issue, REST call of issue shows old status

XMLWordPrintable

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Low
    • None
    • Affects Version/s: 8.19.0, 8.20.10, 8.22.6
    • None
    • 8.19
    • 1
    • Severity 3 - Minor

      Issue Summary

      While doing a workflow tranistion, making a REST call to the issue returns the status pointing to the older value. The post function is set in the end of the sequence after the change history is updated and issue is Reindexed.

      This is reproducible on Data Center: yes

      Steps to Reproduce

      1. Add a postfunction where custom script can be plugged (example: Scriptrunner)
      2. Add the below code, add the correct token project key and base url
        sample-script
        import com.atlassian.jira.component.ComponentAccessor
        import org.apache.commons.httpclient.HttpClient;
        import org.apache.commons.httpclient.HttpStatus;
        import org.apache.commons.httpclient.methods.StringRequestEntity;
        import groovy.json.JsonSlurper;
        import org.apache.commons.httpclient.methods.GetMethod;
        
        import org.apache.log4j.Level
        import org.apache.log4j.Logger
        def log = Logger.getLogger("test-rest")
        log.setLevel(Level.INFO)
        
        def token = "SANTITISED"
        
        def projectKey = 'A4J'
        def baseURL = "http://localhost:8080/jira"
        // def issue = ComponentAccessor.issueManager.getIssueObject("A4J-31")
        def issueKey = issue.key
        
        log.warn("BEGIN TEST...")
        
        // def issueUrl = 'http://localhost:8080/jira' + '/rest/api/2/search?jql=project%3D' + projectKey + '%20and%20issueKey=' + issue.key + '&fields=id,key,status,summary&maxResults=30'
        def issueUrl = 'baseURL/rest/api/2/issue/' + issue.key + '?fields=id,key,status,summary&maxResults=30'
        
        log.info("issueUrl: ${issueUrl}")
        
        HttpClient client = new HttpClient();
        GetMethod get = new GetMethod(issueUrl);
        
        get.setRequestHeader("Authorization", "Bearer ${token}")
        get.setRequestHeader("Accept", "application/json");
        def code = client.executeMethod(get);
        log.info(get.getResponseBodyAsString())
        def parser = new JsonSlurper()
        def json = parser.parseText(get.getResponseBodyAsString())
        log.info("$json")
        
        
        def status = json["fields"]["status"] ["name"]
        // def status = json["issues"][0]["fields"]["status"] ["name"]
        log.info("status is: ${status}")
        log.info("status from bind variable: ${issue.status.name}")
        log.info("status from refetch: : ${ComponentAccessor.issueManager.getIssueObject(issue.key).status.name}")
        
      1. Shuffle it to the end so that the post function is executed in the end
      2. Save the workflow

      Expected Results

      The last three lines of the log should display the same status as they are essentially trying to fetch the same value

      • First is from the REST response
      • Second is from the bind variable
      • Third is from Java API

      Actual Results

      logs
      2022-09-29 21:07:41,882 INFO [test-rest]: status is: To Do
      2022-09-29 21:07:41,882 INFO [test-rest]: status from bind variable: In Progress
      2022-09-29 21:07:41,883 INFO [test-rest]: status from refetch: : In Progress
      

      Workaround

      Use the Other two working methods, however if the actual implementation may require REST call alone for later part, this data can't be used.

            Assignee:
            Unassigned
            Reporter:
            Anupam Singh Deo (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: