Skip to content

Commit b793489

Browse files
committed
better warning message
1 parent 80e8f16 commit b793489

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

programs/server/Server.cpp

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -828,6 +828,8 @@ void loadStartupScripts(const Poco::Util::AbstractConfiguration & config, Contex
828828
config.keys("startup_scripts", keys);
829829

830830
SetResultDetailsFunc callback;
831+
std::vector<String> skipped_startup_scripts;
832+
831833
for (const auto & key : keys)
832834
{
833835
std::string full_prefix = "startup_scripts." + key;
@@ -854,17 +856,17 @@ void loadStartupScripts(const Poco::Util::AbstractConfiguration & config, Contex
854856
executeQuery(condition_read_buffer, condition_write_buffer, true, startup_context, callback, QueryFlags{ .internal = true }, std::nullopt, {});
855857

856858
auto result = condition_write_buffer.str();
857-
858859
if (result != "1\n" && result != "true\n")
859860
{
860861
if (result != "0\n" && result != "false\n")
861-
context->addOrUpdateWarningMessage(
862-
Context::WarningType::SKIPPING_CONDITION_QUERY,
863-
PreformattedMessage::create(
864-
"The condition query returned `{}`, which can't be interpreted as a boolean (`0`, "
865-
"`false`, `1`, `true`). Will skip this query.",
866-
result));
867-
862+
{
863+
LOG_DEBUG(
864+
log,
865+
"Skipping startup script as condition query returned value `{}` "
866+
"which can't be interpreted as a boolean (`0`, `false`, `1`, `true`).",
867+
result);
868+
skipped_startup_scripts.emplace_back(full_prefix);
869+
}
868870
continue;
869871
}
870872

@@ -880,6 +882,16 @@ void loadStartupScripts(const Poco::Util::AbstractConfiguration & config, Contex
880882
executeQuery(read_buffer, write_buffer, true, startup_context, callback, QueryFlags{ .internal = true }, std::nullopt, {});
881883
}
882884

885+
if (!skipped_startup_scripts.empty())
886+
{
887+
context->addOrUpdateWarningMessage(
888+
Context::WarningType::SKIPPING_CONDITION_QUERY,
889+
PreformattedMessage::create(
890+
"Skipped the following startup script(s): {} as the condition query for those returned values, "
891+
"which can't be interpreted as a boolean (`0`, `false`, `1`, `true`).",
892+
fmt::join(skipped_startup_scripts, ", ")));
893+
}
894+
883895
CurrentMetrics::set(CurrentMetrics::StartupScriptsExecutionState, StartupScriptsExecutionState::Success);
884896
}
885897
catch (...)

0 commit comments

Comments
 (0)