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

Requesting required reviewers allows commit hashes in the sourceRefId field

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Low Low
    • None
    • 8.0.5
    • API - REST

      Issue Summary

      This is reproducible on Data Center: Yes

      The API docs state that a SourceRefID needs to be specified in the required reviewers request. A valid RefID is considered a branch or tag name, but it is possible to put a commit hash in the SourceRefID field. Only branch or tags should be allowed. 

      If there are 2 source branches with the same commit hash, it's not clear which branch the required reviewers will be obtained from. 

      Steps to Reproduce

       

      Perform a call to endpoint,

      rest/default-reviewers/1.0/projects/{projectKey}/repos/{repositorySlug}/reviewers

       Set SourceRefID set to the commit hash of the head of the source branch.

      http://<bitbucket>:7990/rest/default-reviewers/1.0/projects/{projectKey}/repos/{repositorySlug}/reviewers?sourceRepoId=sourceRepoId&targetRepoId=targetRepoId&sourceRefId=6b06eb0f9b8&targetRefId=branchName

      Expected Results

      An error showing the RefId cannot be found in the repo : 

      http://centos001:7990/rest/default-reviewers/1.0/projects/\{projectKey}/repos/{repositorySlug}/reviewers?sourceRepoId=2&targetRepoId=2&sourceRefId=6b06eb0f9b8&targetRefId=branchName (404)cache-control: no-cache, no-transform
      connection: keep-alive
      content-encoding: gzip
      content-type: application/json;charset=UTF-8
      date: Thu, 14 Jul 2022 00:38:15 GMT
      keep-alive: timeout=60
      transfer-encoding: chunked
      vary: x-ausername,x-auserid,cookie,accept-encoding
      x-arequestid: @1AXD1TJx1298x110x0
      x-asessionid: 100w2gg
      x-auserid: 52
      x-ausername: Admin
      x-content-type-options: nosniff
      { "errors": [
      { "context": null, "message": "Repository TES/pssrv-42288 doesn't have a 6b06eb0f9b8 ref.", "exceptionName": "com.atlassian.bitbucket.repository.NoSuchBranchException" }
      ]
      }
      

       

      Actual Results

      The reviewers are returned. 

      http://ubuntu005:7990/rest/default-reviewers/1.0/projects/{projectKey}/repos/{repositorySlug}/reviewers?sourceRepoId=2&targetRepoId=2&sourceRefId=6b06eb0f9b8&targetRefId=branchName (200)
      cache-control: no-cache, no-transform
      connection: keep-alive
      content-encoding: gzip
      content-type: application/json
      date: Thu, 14 Jul 2022 00:02:01 GMT
      keep-alive: timeout=60
      transfer-encoding: chunked
      vary: x-ausername,x-auserid,cookie,accept-encoding
      x-arequestid: @BHLZU2x2x2706x0
      x-asessionid: 1k8ng6i
      x-auserid: 2
      x-ausername: Admin
      x-content-type-options: nosniff
      
      [
        {
          "name": "Reviewer",
          "emailAddress": "Reviewer@test.test",
          "id": 4,
          "displayName": "Reviewer",
          "active": true,
          "slug": "reviewer",
          "type": "NORMAL",
          "links": {
            "self": [
              {
                "href": "http://ubuntu005:7990/users/reviewer"
              }
            ]
          }
        }
      ] 

      Workaround

      N/A

              Unassigned Unassigned
              e74118b4e28d David Jansons
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated: