From 58c4528a1c9ae4e7ab57f6c525014fc17d4edfab Mon Sep 17 00:00:00 2001 From: David Taylor Date: Thu, 22 Aug 2024 12:09:56 +0100 Subject: [PATCH] DEV: Replace silent theme-install fails with exceptions (#28485) Previously, we were silently failing when a theme hit SSRF protection, or the `git clone` command failed for some reason. This commit updates them to be exceptions, so they provide more useful error messages --- lib/theme_store/git_importer.rb | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/lib/theme_store/git_importer.rb b/lib/theme_store/git_importer.rb index ee7e6901594..3b734fdbd35 100644 --- a/lib/theme_store/git_importer.rb +++ b/lib/theme_store/git_importer.rb @@ -115,20 +115,21 @@ class ThemeStore::GitImporter < ThemeStore::BaseImporter addresses = FinalDestination::SSRFDetector.lookup_and_filter_ips(uri.host) - unless addresses.empty? - env = { "GIT_TERMINAL_PROMPT" => "0" } + raise_import_error! if addresses.empty? - args = - clone_args( - uri.to_s, - "http.followRedirects" => "false", - "http.curloptResolve" => "#{uri.host}:#{uri.port}:#{addresses.join(",")}", - ) + env = { "GIT_TERMINAL_PROMPT" => "0" } - begin - Discourse::Utils.execute_command(env, *args, timeout: COMMAND_TIMEOUT_SECONDS) - rescue RuntimeError - end + args = + clone_args( + uri.to_s, + "http.followRedirects" => "false", + "http.curloptResolve" => "#{uri.host}:#{uri.port}:#{addresses.join(",")}", + ) + + begin + Discourse::Utils.execute_command(env, *args, timeout: COMMAND_TIMEOUT_SECONDS) + rescue RuntimeError + raise_import_error! end end