Skip to content

Handle securityReportFinding GraphQL query when no pipeline findings

What does this MR do and why?

The securityReportFinding GraphQL query responds with an error instead of null when the requested pipeline has no findings. This MR allows the query to gracefully handle the lack of findings by checking for a null value before pulling the finding.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

How to set up and validate locally

  1. Run a pipeline on a new project to generate security findings (https://gitlab.com/gitlab-examples/security/security-reports is a good choice).
  2. Delete all of the security findings for the pipeline
Ci::Pipeline.where(project: Project.find(<project id>)).last.security_findings.map(&:destroy)
  1. Run the GraphQL query, it should return null on the branch, but throw an error on master. Note the uuid does not matter.
{
  project(fullPath: "<project path>") {
    pipeline(iid: "1") {
      securityReportFinding(uuid: "any-uuid") {
        title
        reportType
      }
    }
  }
}

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #382759 (closed)

Edited by Jonathan Schafer

Merge request reports

Loading