diff options
Diffstat (limited to 'lib/gitlab/background_migration/migrate_links_for_vulnerability_findings.rb')
-rw-r--r-- | lib/gitlab/background_migration/migrate_links_for_vulnerability_findings.rb | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/lib/gitlab/background_migration/migrate_links_for_vulnerability_findings.rb b/lib/gitlab/background_migration/migrate_links_for_vulnerability_findings.rb index 222ee4e524e..0e38be3b4c9 100644 --- a/lib/gitlab/background_migration/migrate_links_for_vulnerability_findings.rb +++ b/lib/gitlab/background_migration/migrate_links_for_vulnerability_findings.rb @@ -37,14 +37,16 @@ module Gitlab next unless list_of_attrs.present? - create_links(list_of_attrs) - rescue ActiveRecord::RecordNotUnique - rescue StandardError => e - logger.error( - message: e.message, - class: self.class.name, - model_id: finding.id - ) + begin + create_links(list_of_attrs) + rescue ActiveRecord::RecordNotUnique + rescue StandardError => e + logger.error( + message: e.message, + class: self.class.name, + model_id: finding.id + ) + end end end @@ -65,10 +67,11 @@ module Gitlab def extract_links(metadata) parsed_metadata = Gitlab::Json.parse(metadata) + parsed_links = Array.wrap(parsed_metadata['links']) - return [] unless parsed_metadata['links'] + return [] if parsed_links.blank? - parsed_metadata['links'].compact.uniq + parsed_links.select { |link| link.try(:[], 'url').present? }.uniq end def logger |