REST API endpoints for creating default reviewer conditions do not validate the "requiredApprovals" value

XMLWordPrintable

    • Type: Bug
    • Resolution: Won't Fix
    • Priority: Low
    • None
    • Affects Version/s: 8.9.0, 8.19.0, 9.4.0, 9.6.0
    • Component/s: API - REST
    • 1
    • Severity 3 - Minor
    • 1
    • CtB - Improve Existing

      Issue Summary

      The REST API endpoints for creating default reviewer conditions do not validate the "requiredApprovals" value passed in the payload:

      REST APIs:

      Because there's no validation, it is possible to create default reviewer conditions where the number of approvals required exceeds the configured default reviewers:

      Samples:

      In contrast, the UI caps the number of "Approvals required" dropdown field based on the number of users in the "Default reviewers" field:

      Steps to Reproduce

      Create default reviewer conditions via API.

      Sample:

      curl -k -u <BITBUCKET_ADMIN_USER> '<BITBUCKET_BASE_URL>/rest/default-reviewers/latest/projects/PROJ1/repos/repo1/condition' \
      -H 'Content-Type: application/json' \
      -d '{
          "sourceMatcher": {
              "active": true,
              "id": "ANY_REF_MATCHER_ID",
              "displayId": "ANY_REF_MATCHER_ID",
              "type": {
                  "id": "ANY_REF",
                  "name": "Any branch"
              }
          },
          "targetMatcher": {
              "id": "refs/heads/master",
              "displayId": "master",
              "type": {
                  "id": "BRANCH",
                  "name": "Branch"
              },
              "active": true
          },
          "reviewers": [
              {
                  "slug": "user1",
                  "id": 52
              },
              {
                  "slug": "user2",
                  "id": 102
              }        
          ],
          "requiredApprovals": 100
      }'
      
      • set "requiredApprovals" to 100
      • however, there are only 2 users in the "reviewers" list

      Expected Results

      API endpoints should not allow setting "requiredApprovals" value to be more than the users in the "reviewers" list.

      It should have validation consistent with the Bitbucket UI behavior.

      Actual Results

      It's possible to create default reviewer conditions where the "requiredApprovals" value is more than the number of reviewers.

      Workaround

      Create default reviewer conditions via the UI.

        1. default-reviewers-created-via-api.png
          359 kB
          JP Mariano
        2. default-reviewers-modal.png
          509 kB
          JP Mariano

            Assignee:
            Unassigned
            Reporter:
            JP Mariano
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: