From: Remi Gacogne Date: Mon, 24 Mar 2025 15:37:58 +0000 (+0100) Subject: dnsdist: Better handling of non-existent Lua function name in YAML X-Git-Tag: dnsdist-2.0.0-alpha2~113^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d41c7fbf421a9c83f5171dd99b0b2fe416057637;p=thirdparty%2Fpdns.git dnsdist: Better handling of non-existent Lua function name in YAML This commit changes the way DNSdist handles a non-existent Lua function name being referenced from the YAML configuration: instead of silently ignoring the problem, it loudly complains before exiting. --- diff --git a/pdns/dnsdistdist/dnsdist-configuration-yaml.cc b/pdns/dnsdistdist/dnsdist-configuration-yaml.cc index 00d2c5aa1d..a707ec419a 100644 --- a/pdns/dnsdistdist/dnsdist-configuration-yaml.cc +++ b/pdns/dnsdistdist/dnsdist-configuration-yaml.cc @@ -144,7 +144,11 @@ template static bool getLuaFunctionFromConfiguration(FuncType& destination, const ::rust::string& functionName, const ::rust::string& functionCode, const ::rust::string& functionFile, const std::string& context) { if (!functionName.empty()) { - return getOptionalLuaFunction(destination, functionName); + auto found = getOptionalLuaFunction(destination, functionName); + if (found) { + return true; + } + throw std::runtime_error("Unable to locate the Lua function named '" + std::string(functionName) + "', referenced by a lua directive in " + context + " context"); } if (!functionCode.empty()) { auto function = dnsdist::lua::getFunctionFromLuaCode(std::string(functionCode), context);