From 1904b4017c4a72db46ddad01901e1fb32dfacd7c Mon Sep 17 00:00:00 2001
From: Alexander Olofsson <alexander.olofsson@liu.se>
Date: Mon, 16 Jan 2023 15:59:33 +0100
Subject: [PATCH] Skip host search if no uuid fact exists

---
 .../unattended_installation/concerns/host_finder_extensions.rb  | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/app/services/foreman/unattended_installation/concerns/host_finder_extensions.rb b/app/services/foreman/unattended_installation/concerns/host_finder_extensions.rb
index 60d95fe..d9be12b 100644
--- a/app/services/foreman/unattended_installation/concerns/host_finder_extensions.rb
+++ b/app/services/foreman/unattended_installation/concerns/host_finder_extensions.rb
@@ -15,6 +15,8 @@ module ForemanUuidBoot
       return unless (uuid = query_params['uuid'])
 
       fact_name_id = FactName.where(name: 'uuid').map(&:id)
+      return unless fact_name_id.any?
+
       query = { fact_values: { fact_name_id: fact_name_id, value: uuid } }
       hosts = Host.joins(:fact_values).where(query).order(:created_at)
 
-- 
GitLab