Skip to content

Unlink MR and vulnerability mutation

What does this MR do and why?

Add a mutation for unlinking an MR from a vulnerability.

In !202437 (merged) we added the mutation for linking an MR to a vulnerability. This MR is adding the mutation for unlinking.

References

Related to #503408

Screenshots or screen recordings

Screenshot_2025-09-26_at_11.42.06_AM

How to set up and validate locally

  1. Navigate to a project with a vulnerability. If you need to seed a project, you can do so with bin/rake 'gitlab:seed:vulnerabilities[<your-project-path>]'
  2. Create an MR and get the GID from dev tools (the UI only shows the IID)
  3. In the graphql explorer /-/graphql-explorer make the following mutation to link the MR to a vulnerability
mutation linkMergeRequest {
  vulnerabilityLinkMergeRequest(input: {
    vulnerabilityId: "gid://gitlab/Vulnerability/<your-vulnerability-gid>",
    mergeRequestId: "gid://gitlab/MergeRequest/<your-MR-gid>"
  }) {
    vulnerability {
      id
      mergeRequest {
        id
        title
      }
      mergeRequests {
        nodes {
          id
          title
        }
      }
    }
  }
}
  1. You can double check that the merge request was linked to the vulnerability by making another query
query getVulnerability {
  vulnerability(id: "gid://gitlab/Vulnerability/<your-vulnerability-gid>") {
    id
    mergeRequest {
      id
      title
    }
    mergeRequests {
      nodes {
        id
        title
      }
    }
  }
}
  1. Now make the following mutation to unlink the MR from the vulnerability
mutation unlinkMergeRequest {
  vulnerabilityUnlinkMergeRequest(input: {
    vulnerabilityId: "gid://gitlab/Vulnerability/<your-vulnerability-gid>",
    mergeRequestId: "gid://gitlab/MergeRequest/<your-MR-gid>"
  }) {
    vulnerability {
      id
      mergeRequest {
        id
        title
      }
      mergeRequests {
        nodes {
          id
          title
        }
      }
    }
  }
}
  1. Verify that the MR is no longer linked to the vulnerability

MR acceptance checklist

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

Edited by Scott Hampton

Merge request reports

Loading