Bug: Resolve MR link appearing in ETV
There's an edge case with the explain vuln / resolve vuln where the MR link would appear on the explain this vulnerability drawer when the user triggers multiple AI actions in a very specific manner:
Click on the "Explain this vulnerability"
|--> immediately close the drawer
|--> click on the "Resolve with AI"
|--> immediately click on the "Explain this vulnerability"
Screenshot | Video |
---|---|
![]() |
mr-link-appearing-in-etv |
Steps to reproduce
- Have the related FF enabled:
echo "Feature.enable(:resolve_vulnerability_ai)" | rails c
- In order to run a pipeline to generate a Vulnerability report, you'll need an EE license.
- Fork https://gitlab.com/gitlab-org/security-products/tests/webgoat.net
- Run a pipeline against the default branch. It will generate vulnerabilities.
- Go to the project vulnerability report page
- Click on the "Explain this vulnerability", and immediately close the drawer
- Click on the "Resolve with AI", and immediately click on the "Explain this vulnerability"
Note: this can be quite tricky to reproduce. Tips:
- An easy way to trigger it is to see how long it takes on average to create the MR, then subtract a second or two and open the Explain Vuln drawer
- OR to make it even easier, comment out the code that redirects the user and make it so that the drawer doesn't call the aiAction mutation when it's opened. Then just click the resolve button, open the drawer, then wait. You can utilize this patch > reproduce-ai-race-problem.patch
Example Project
What is the expected correct behavior?
The explain vulnerability should NOT display the output of the AI generated MR link.
Possible fixes
We can fix it by sending a different aiAction
variable for explain vuln and resolve vuln: https://gitlab.com/gitlab-org/gitlab/-/blob/9c2a34e90127eb54dd230a4eaa575262e6ba2a[…]hared/subscriptions/ai_completion_response.subscription.graphql
The AiAction
seems to accept only ENUM values, and currently, it only supports the "CHAT" parameter. So some backend updates will also be needed.
- backend adds support for "RTV" and "ETV" in action_enum.rb
-
frontend updates the subscription and send a different
aiAction
variable.- RTV: headers.vue
- ETV: explain_vulnerability_drawer
Edited by Samantha Ming