"Stop" button for deployment jobs fails in Merge Request widget UI

Summary

When clicking the "Stop" button to stop an environment in a Merge Request (MR) widget, the "Stop" job does not run and a stack trace is generated in the console.

Steps to reproduce

  1. Set up a Pipeline with a deploy_environment and stop_environment jobs as follows:
Click to expand
stages:
  - deploy
  - stop


deploy_environment:
    stage: deploy
    environment:
        name: production
        on_stop: stop_environment
    script:
        - exit 0
    rules:
    - if: $CI_MERGE_REQUEST_ID

stop_environment:
    stage: stop
    environment:
        name: production
        action: stop
    script:
        - exit 0
    when: manual
    rules:
    - if: $CI_MERGE_REQUEST_ID
  1. Create a Merge Request based off the above branch, an MR pipeline should run.
  2. Wait for the deploy_environment job to complete successfully, creating the production environment.
  3. Click the stop_environment job button from the MR widget; the job does not run and the environment isn't stopped.

image

Example Project

https://gitlab.com/alejguer_ultimate_group/recreations/environmentstopbutton/-/merge_requests/1

What is the current bug behavior?

The "Stop" job does not run and the environment is not stopped.

Relevant logs and/or screenshots

The following is logged in the Web console when clicking on the button:

job_action_button.vue:106 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'error')
    at a.executeJobAction (job_action_button.vue:106:1)
    at a.onActionButtonClick (job_action_button.vue:88:1)
    at click (job_action_button.vue:1:470)
    at mn (vue.runtime.esm.js:3033:30)
    at n (vue.runtime.esm.js:1832:20)
    at mn (vue.runtime.esm.js:3033:30)
    at HTMLButtonElement.n (vue.runtime.esm.js:1827:17)
    at HTMLButtonElement.<anonymous> (vue.runtime.esm.js:7500:35)
    at HTMLButtonElement.r (helpers.js:94:17)

Output of checks

This bug happens on GitLab.com

Workarounds

  1. You can still run the "Stop" button from the pipeline/job view.
  2. The "Stop environment" button also allows the environment to be stopped:

image

Possible fixes

Update the job_action_button to support stop action. It can use the same data as play action, as it's actually playing the stop job.

Last MR that modified affected file is Job updates in PMG - Re-route pmg dropdowns to ... (!171862 - merged)

Labeling issue with the above group initially.

Edited by 🤖 GitLab Bot 🤖