Merge queue logs a successfully merged pull request as closed with state OPEN

XMLWordPrintable

    • 1
    • Severity 3 - Minor
    • 3

      Issue Summary

      When a pull request is merged by a merge queue, Bitbucket writes a debug log entry reporting the state of the pull request as it is removed from the queue. That entry reports the state the pull request held before the merge was applied rather than the state it holds afterwards, so a pull request that merged successfully is reported as OPEN rather than MERGED.

      The log entry is only written when the pull request has in fact been closed, so the state it reports is incorrect every time the entry appears.

      This is a logging defect only. The merge itself is unaffected, the pull request is correctly marked as merged, and the pull request is correctly removed from the merge queue. There is no impact on the outcome of any merge.

      It is nonetheless misleading during troubleshooting. The entry is written immediately before a second entry recording that the pull request is being ejected from the merge queue, so the pair reads as though a pull request were being removed from the queue in an inconsistent state, when in fact both entries are part of the normal successful path.

      The entry is written at debug level, so it is only visible when debug logging has been enabled for the merge queue. That is typically done while investigating a merge queue problem, which is precisely when a misleading entry is most likely to cause a wrong conclusion to be drawn.

      Steps to Reproduce

      1. Use a Data Center instance with a merge queue enabled on a branch.
      2. Enable debug logging for the merge queue, for example with PUT /rest/api/latest/logs/logger/com.atlassian.bitbucket.internal.mergequeue/debug.
      3. Create a pull request targeting that branch, add it to the merge queue, and allow it to pass its checks and merge.
      4. Search atlassian-bitbucket.log for closed with state.

      Expected Results

      The entry reports the state the pull request holds after the merge has been applied.

      DEBUG [merge-queue-executor:thread-6] c.a.b.i.m.p.s.StrictPerPullRequestStrategy [1]: Pull request 456 closed with state MERGED
      

      Actual Results

      The entry reports the state the pull request held before the merge was applied, which is always OPEN.

      DEBUG [merge-queue-executor:thread-6] c.a.b.i.m.p.s.StrictPerPullRequestStrategy [1]: Pull request 456 closed with state OPEN
      

      The entry is followed by the ejection entry for the same pull request, which is the expected behaviour for a pull request that has merged successfully.

      DEBUG [merge-queue-executor:thread-6] c.a.b.i.m.MergeQueueEjectionHandler [1]: Ejecting pull request 456 from the queue
      

      Workaround

      Currently there is no known workaround for this behavior. A workaround will be added here when available.

              Assignee:
              Unassigned
              Reporter:
              Josh Aguilar
              Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: