Skip to content

Adds type to issue webhook attributes

What does this MR do and why?

Contributes to Add (work item) type to issue events webhook (#467415 - closed) (&10150 (comment 1953253582) also contains a discussion about this approach)

Right now the issue events webhook triggers on updates for legacy issues, Service Desk issues, Incidents and all new work item types. But there's no way to tell which type a given work item is from the event payload.

this MR adds the type attribute to object_attributes of the request payload. type contains the name of the work item type, which is always available, also for legacy issues.

This works for issue events and confidential issue events because we use the same lib/gitlab/hook_data/issue_builder.rb for both events.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After
image image

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. Open a project that has at least one issue.
  2. Navigate to Settings and Webhooks and select Add new webhook.
  3. Fill fields:
    1. Use a public webhook listening service or build one on your own. For example, you can use a webhook URL generated by https://webhook.site/ and paste it into the webhook form. I think you could also use https://example.com/ (untested). We'll look at the webhook logs in GitLab for this validation, so the URL doesn't really matter.
    2. Add a name and add a secret token (e.g. super-secret-token-42).
    3. Select issues events and deselect Enable SSL verification (depending on your selected webhook URL)
  4. Select Add webhook.
  5. Then select edit for the newly created webhook and scroll to the bottom of the page.
  6. Expand the Test multiselect and select Issues events. This reloads the page.
  7. At the bottom of the section Recent events you should see the test event. Select View details.
  8. In the Request section you should find type under object_attributes (probably with the value Issue.
  9. (Optional) If you want to double-check this, you can also create a task on that issue, get back to the webhook page and find the event for the created tasks. Here type should be Task and the top-level object_kind should be work_item.
Edited by Marc Saleiko

Merge request reports