diff --git a/lib/gitlab/import_export/relation_factory.rb b/lib/gitlab/import_export/relation_factory.rb
index dd7f9e2fd65117eb8683b11f68cbb615d0780748..0319d7707a8bc417eda04cbc7baf63193a43b750 100644
--- a/lib/gitlab/import_export/relation_factory.rb
+++ b/lib/gitlab/import_export/relation_factory.rb
@@ -154,7 +154,7 @@ module Gitlab
       end
 
       def remove_encrypted_attributes!
-        return if relation_class.encrypted_attributes.empty?
+        return unless relation_class.respond_to?(:encrypted_attributes) && relation_class.encrypted_attributes.any?
 
         relation_class.encrypted_attributes.each_key do |key|
           @relation_hash[key.to_s] = nil