Skip to content

Don't allow duplicate resource links (by URL) in incidents

In incidents, you can add duplicate resource links:

image

This doesn't seem very useful to allow, and could be confusing when the link text is different.

Implementation guide

  1. Return an error saying "URL already linked" in IncidentManagement::IssuableResourceLinks::Create
    • For this, we need to check if the incident already links a resource with the same link
      • For the sake of simplicity we are not normalizing URLs which means that these URLs are identical: https://example.org and https://example.org/ (note the trailing slash)
    • For example, incident.issuable_resource_links.where(link: params[:link]).exists?
    • Check if the existing index (index_issuable_resource_links_on_issue_id) is speedy
    • 🅰 If not (due to too many linked resources per issue)
      • Consider a composite index on issue_id, link
      • Limit amount of resources per issue to 100. This would also have some positive implications on the UX. See splattael/mwps#21.
  2. 🅱 Ensure that the service response's message is properly propagated to the user. Currently, we fail to say why saving a resource link is failing.

Note that 🅰 and 🅱 could be separate MRs.

Additional guidance:

Edited by Peter Leitzen