Skip to content

Fix webhook failure callout still displaying even after dismissed

What does this MR do and why?

This merge request fixes the webhook failure callout from sometimes still displaying even after being dismissed.

This bug only happened on some pages (for example, the main project page).

The problem happened because on some pages the object passed to #web_hook_disabled_dismissed? is a ProjectPresenter (a wrapped Project). Although most calls to the presenter are delegated to the wrapped project, the #class call isn't. #class is returned as ProjectPresenter, so the check for whether the class has mixed in WebHooks::HasWebHooks fails.

On the main project page, object is a ProjectPresenter, but on an issue page, it is a Project, so it worked correctly on issue pages.

The change is to instead check if the object responds to a particular method we call on the next line.

How to set up and validate locally

  1. Enable the auto-disabling webhook feature
    Feature.enable(:auto_disabling_web_hooks)
  2. Create a project webhook:
    1. Choose a project, go Settings > Webhooks.
    2. For URL enter https://httpstat.us/500 which will return a 500 error response.
    3. For Trigger, select Issues events.
    4. Click Add webhook.
  3. Go Issues > List and choose and issue.
    1. Close, reopen, close, reopen, close and reopen the issue to generate lots of webhook triggers.
  4. Visit the project page, you should see a callout banner about the failed webhook.
  5. Dismiss it.
  6. Reload the page, it should not reappear.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Merge request reports

Loading