diff --git a/lib/gitlab/markdown/redactor_filter.rb b/lib/gitlab/markdown/redactor_filter.rb
index 92925f866a92e3e687740ab32d7f7aad50d544a9..ae1c3c365bd0e0d04fe5da515825638e12067014 100644
--- a/lib/gitlab/markdown/redactor_filter.rb
+++ b/lib/gitlab/markdown/redactor_filter.rb
@@ -35,12 +35,16 @@ module Gitlab
         group = Group.find(id)
 
         group && can?(:read_group, group)
+      rescue ActiveRecord::RecordNotFound
+        false
       end
 
       def user_can_reference_project?(id)
         project = Project.find(id)
 
         project && can?(:read_project, project)
+      rescue ActiveRecord::RecordNotFound
+        false
       end
 
       def user_can_reference_user?(id)