FIX: Load base color scheme when default theme is not set

FIX: Load base color scheme when default theme is not set

Followup to c937afc

diff --git a/lib/stylesheet/manager.rb b/lib/stylesheet/manager.rb
index fbdf89d..819c4bc 100644
--- a/lib/stylesheet/manager.rb
+++ b/lib/stylesheet/manager.rb
@@ -97,7 +97,7 @@ class Stylesheet::Manager
     color_scheme = begin
       ColorScheme.find(color_scheme_id)
     rescue
-      Theme.find(SiteSetting.default_theme_id).color_scheme || ColorScheme.base
+      Theme.find_by_id(SiteSetting.default_theme_id)&.color_scheme || ColorScheme.base
     end
 
     target = COLOR_SCHEME_STYLESHEET.to_sym
diff --git a/spec/components/stylesheet/manager_spec.rb b/spec/components/stylesheet/manager_spec.rb
index f99a403..692b728 100644
--- a/spec/components/stylesheet/manager_spec.rb
+++ b/spec/components/stylesheet/manager_spec.rb
@@ -171,6 +171,12 @@ describe Stylesheet::Manager do
       expect(link).not_to eq("")
     end
 
+    it "does not crash when no default theme is set" do
+      SiteSetting.default_theme_id = -1
+      link = Stylesheet::Manager.color_scheme_stylesheet_link_tag()
+      expect(link).not_to eq("")
+    end
+
     it "does not crash on missing color scheme" do
       link = Stylesheet::Manager.color_scheme_stylesheet_link_tag(125)
       expect(link).not_to eq("")

GitHub sha: 266c0c50