Uploaded image for project: 'Bitbucket Data Center'
  1. Bitbucket Data Center
  2. BSERV-12431

Switching between code insights reports with similar annotations duplicates displayed annotations

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Low
    • 7.5.0
    • 7.1.4, 7.3.1, 7.2.5
    • Code Insights

    Description

      Issue Summary

      When a user switches between two different code insights reports that have annotations that have the same type, message, and severity - these affected annotations are not cleared out when you switch and begin to duplicate each time you switch between the reports.

      Steps to Reproduce

      1. PUT two new reports against the latest commit on a pull request. Ex:
        • curl --location --request PUT 'https://mybitbucketinstance.com/rest/insights/latest/projects/test/repos/test/commits/37a567b70176fb6f93929b9d7488e90bdcd38224/reports/test' \
          --header 'Accept: application/json' \
          --header 'Content-Type: application/json' \
          -u adminusername:adminpassword \
          --data-raw '{
                "data": [
                  {
                    "title": "This is a test",
                    "value": "2"
                  }
                ],
                "details": "Test",
                "logoUrl": "https://thisisatesturlandisnotreal.test",
                "result": "FAIL",
                "title": "Test",
                "reporter": "Test"
          }'
          curl --location --request PUT 'https://mybitbucketinstance.com/rest/insights/latest/projects/test/repos/test/commits/37a567b70176fb6f93929b9d7488e90bdcd38224/reports/test2' \
          --header 'Accept: application/json' \
          --header 'Content-Type: application/json' \
          -u adminusername:adminpassword \
          --data-raw '{
                "data": [
                  {
                    "title": "This is a test 2",
                    "value": "2"
                  }
                ],
                "details": "Test 2",
                "logoUrl": "https://thisisatesturlandisnotreal.test",
                "result": "FAIL",
                "title": "Test 2",
                "reporter": "Test 2"
          }'
      2. POST two annotations to one report, and only one to the second report. Ensure that the report with two annotations has both annotations with the same type, message, and severity. The path/line number do not matter (as long as they exist and were modified in the PR) and can be unique. Ex:
        • curl --location --request POST 'https://mybitbucketinstance.com/rest/insights/latest/projects/test/repos/test/commits/37a567b70176fb6f93929b9d7488e90bdcd38224/reports/test/annotations' \
          --header 'Accept: application/json' \
          --header 'Content-Type: application/json' \
          -u adminusername:adminpassword \
          --data-raw '{
              "annotations": [
              {
                "line": 13,
                "message": "test",
                "path": "src/main/Test.java",
                "severity": "LOW",
                "type": "CODE_SMELL"
              },
              {
                "line": 14,
                "message": "test",
                "path": "src/main/Test.java",
                "severity": "LOW",
                "type": "CODE_SMELL"
              }
              ]
          }'
          curl --location --request POST 'https://mybitbucketinstance.com/rest/insights/latest/projects/test/repos/test/commits/37a567b70176fb6f93929b9d7488e90bdcd38224/reports/test2/annotations' \
          --header 'Accept: application/json' \
          --header 'Content-Type: application/json' \
          -u adminusername:adminpassword \
          --data-raw '{
              "annotations": [
              {
                "line": 15,
                "message": "test 2",
                "path": "src/main/Test.java",
                "severity": "MEDIUM",
                "type": "BUG"
              }
              ]
          }'
      3. On the pull request overview screen, click where it says '2 Integrations' in the top right, and then switch between both reports multiple times.

      Expected Results

      Switching between both reports shows the expected 2 annotations for 'Test' and 1 annotation for 'Test 2'.

      Actual Results

      Every time you switch between Test to Test 2, one of the two annotations is duplicated as it doesn't get cleared from the annotation list:

      The reason for this is because the unique identifier for annotations is a composite key comprised of the message, type, severity, and report key. When switching between reports, the annotations list will only clear out one instance of each key - meaning that the second instance of any key will remain within the report listing.

      The only exception to the above behavior is when you visit a report with no annotations. This will clear out all annotations (including the duplicate ones) until you start switching between the two populated reports again.

      Workaround

      Ensure all annotations have a unique report/message/severity/type combination.

      Attachments

        Activity

          People

            mdiberardino@atlassian.com Matt Di Berardino
            eslaughter@atlassian.com Evan Slaughter
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Backbone Issue Sync