Gate pipeline creation failure alerts on user-initiated requests

What does this MR do and why?

The MR Pipelines tab currently shows "Pipeline creation failed. Please try again." whenever a creation request fails. The trouble is that a lot of those requests are automatic: GitLab kicks one off when you open an MR, push to the source branch, or retarget. When one of those fails, the author gets an error for something they never did. We agreed to gate the alert in this thread using a user_initiated flag.

The fix is a small shared helper, alertableFailedRequests, that keeps only the failures that were user initiated and have not already been dismissed. Both the GraphQL wrapper and the legacy wrapper (still in use while mr_pipelines_graphql is off) run their alert through it, so an automatic failure stays quiet. Reading userInitiated is why the query and subscription now select it alongside id, the fields Add user_initiated flag to MR pipeline creation... (!249876 - merged) added.

I also made the alert dismissals stick. Dismissing the alert stores the failed request UUIDs in localStorage, scoped per project and MR and capped at the 20 most recent, so a dismissed failure stays hidden after a reload while a new failure still alerts. It is per browser, the usual trade-off for UI state like this.

How to validate

  1. In a project whose CI config yields no merge request pipeline jobs (a single job with rules: [{ if: '$CI_COMMIT_TAG' }] works), open an MR.

  2. Trigger an automatic attempt from the rails console.

    mr = MergeRequest.find(<id>)
    MergeRequests::CreatePipelineService
      .new(project: mr.project, current_user: mr.author, params: { allow_duplicate: true })
      .execute_async(mr)
  3. Open the MR's Pipelines tab within 5 minutes (the Redis TTL of the request hash). No alert shows; on master this shows the failure alert.

  4. Select Run pipeline on the tab, or comment /run_pipeline. The creation fails and the alert appears in real time.

    mr_pipelines_failure_alert
  5. Dismiss the alert and reload the tab within the TTL window. It stays hidden, and the stored UUIDs are visible in localStorage under a key starting with mr_pipelines_dismissed_creation_alerts.

  6. Select Run pipeline again. The new failed request re-alerts.

  7. Disable mr_pipelines_graphql and repeat steps 2 to 5 against the legacy tab.

References

Edited by Sahil Sharma

Merge request reports

Loading
Loading