Improve error communication when enabling Secret Detection using an MR
When enabling Secret Detection from the repository security configuration page, if a repository has an existing .gitlab-ci.yml
that contains anchors/aliases, the action will fail with an error. This is due to a YAML parsing issue (relevant discussion : #326532 (comment 1130382230)).
This error scenario needs to be communicated to users.
Might also be helpful to suggest a workaround (most likely asking them to manually add a snippet to their .gitlab-ci.yml
)
Steps to reproduce
- Create a new repository and add some files to it.
- Within the repository create a
.gitlab-ci.yml
. Specifically, add at least one anchor/alias to it. Check below for an example. - Go to "Security and Compliance" > "Configuration". Scroll down to "Secret Detection" and press "Configure with Merge Request".
- Doing so will lead to an error shown at the top of the page
Steps to Implement
-
Backend should return a specific error when this scenario happens -
Update Security Configuration documentation to reflect a workaround for this scenario. -
Add a "Troubleshooting" section in the Security Configuration documentation explaining why anchors and aliases cannot be parsed correctly. (Helpful discussion) -
Map the received error to show the copy on the front-end
Copy
Secret Detection cannot be enabled automatically using a merge request. The .gitlab-ci.yml
file contains YAML anchors and aliases, and these cannot be processed correctly. Instead, you must manually include the template.
Edited by Arpit Gogia