Handle securityReportFinding GraphQL query when no pipeline findings
requested to merge 382759-securityreportfinding-graphql-query-responds-with-error-instead-of-null-when-pipeline-has-no into master
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
- Run a pipeline on a new project to generate security findings (https://gitlab.com/gitlab-examples/security/security-reports is a good choice).
- Delete all of the security findings for the pipeline
Ci::Pipeline.where(project: Project.find(<project id>)).last.security_findings.map(&:destroy)
- Run the GraphQL query, it should return
null
on the branch, but throw an error onmaster
. Note theuuid
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.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #382759 (closed)
Edited by Jonathan Schafer