Changeset

13744:34ac05f6bd10 13.0

core.configmanager: Fix reporting delayed warnings from global section A Credential in the global section would be stored at delayed_warnings["*/secret"], but get("example.com","secret") would look for delayed_warnings["example.com/secret"] Storing the warnings in the config itself has the unfortunate side-effect that the config now contains util.error objects, which may be awkward if something bypasses get(). Should rawget() also do this filtering? getconfig() too? Currently this only affects prosodyctl, so maybe it won't be much of a problem.
author Kim Alvefur <zash@zash.se>
date Sat, 22 Feb 2025 00:08:18 +0100
parents 13743:0c7e11c11968
children 13745:994ea8d54b72
files core/configmanager.lua
diffstat 1 files changed, 5 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/core/configmanager.lua	Sat Feb 22 00:00:41 2025 +0100
+++ b/core/configmanager.lua	Sat Feb 22 00:08:18 2025 +0100
@@ -34,7 +34,6 @@
 
 local config_mt = { __index = function (t, _) return rawget(t, "*"); end};
 local config = setmetatable({ ["*"] = { } }, config_mt);
-local delayed_warnings = {};
 local files = {};
 local credentials_directory = nil;
 local credential_fallback_fatal = true;
@@ -47,11 +46,12 @@
 end
 
 function _M.get(host, key)
-	if host and key and delayed_warnings[host.."/"..key] then
-		local warning = delayed_warnings[host.."/"..key];
-		log("warn", "%s", warning.text);
+	local v = config[host][key];
+	if v and errors.is_error(v) then
+		log("warn", "%s", v.text);
+		return nil;
 	end
-	return config[host][key];
+	return v;
 end
 function _M.rawget(host, key)
 	local hostconfig = rawget(config, host);
@@ -252,10 +252,6 @@
 						t_insert(warnings, ("%s:%d: Duplicate option '%s'"):format(config_file, get_line_number(config_file), k));
 					end
 					set_options[option_path] = true;
-					if errors.is_error(v) then
-						delayed_warnings[option_path] = v;
-						return;
-					end
 					set(config_table, env.__currenthost or "*", k, v);
 				end
 		});
@@ -385,7 +381,6 @@
 							:format(config_file, get_line_number(config_file));
 					});
 			end
-
 		end
 
 		local chunk, err = envload(data, "@"..config_file, env);