Skip to content

Fix external status check service error responses

What does this MR do and why?

Related to Fix external status checks error responses (#480129 - closed)

  • Fixes the external status check error responses when AllBranchRules or ProtectedBranchRules is passed as branchRuleId in external status checks mutations. Currently, we are returning an empty array.
  • Creates the BranchRules::ExternalStatusChecks::BaseService class to DRY some methods repeated in create, destroy and update services.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

How to set up and validate locally

  1. Create a protected branch and then create a branch rule.
  2. Create an external_status_check record using the API or directly in your Rails console.
  3. Go to https://<YOUR_GDK_HOST>:<YOUR_GDK_PORT>/-/graphql-explorer
  4. Apply the following query:
mutation UpdateMutation($id: MergeRequestsExternalStatusCheckID!, $branchRuleId: ProjectsBranchRuleID!, $name: String!, $externalUrl: String!) {
  branchRuleExternalStatusCheckUpdate(input: {
    id: $id
    branchRuleId: $branchRuleId
    name: $name
    externalUrl: $externalUrl
  }) {
    externalStatusCheck {
      id
      name
      externalUrl
    }
    errors
  }
}

Your query variables could look like this:

{
  "id": "gid://gitlab/MergeRequests::ExternalStatusCheck/1",
  "branchRuleId": "gid://gitlab/Projects::AllBranchesRule/1",
  "name": "hello",
  "externalUrl": "http://google.com"
}
  1. This should return an error like the following:
{
  "data": {
    "branchRuleExternalStatusCheckUpdate": {
      "externalStatusCheck": null,
      "errors": [
        "All branch rules not allowed"
      ]
    }
  }
}
Edited by Javiera Tapia

Merge request reports

Loading