From: Alexander Moisseev Date: Sun, 26 Apr 2026 06:52:22 +0000 (+0300) Subject: [Minor] lua_maps: handle empty table as static empty map X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=54082ebaa63f176b73a054c6f0f705d32470f48a;p=thirdparty%2Frspamd.git [Minor] lua_maps: handle empty table as static empty map When map_add_from_ucl receives an empty Lua table, it fell through to the C map infrastructure, which logged a spurious error-level message with no map name. Return a lightweight empty map object directly in Lua, cache it for consistency with other code paths, and log a warning since an empty table is likely a misconfiguration. --- diff --git a/lualib/lua_maps.lua b/lualib/lua_maps.lua index 80319df41b..c14cc940db 100644 --- a/lualib/lua_maps.lua +++ b/lualib/lua_maps.lua @@ -391,6 +391,19 @@ local function rspamd_map_add_from_ucl(opt, mtype, description, callback) return maps_cache[cache_key] end + if not next(opt) then + -- Empty table: return a static empty map without involving C map infrastructure, + -- avoiding a spurious error log when an intentionally empty default is used. + rspamd_logger.warnx(rspamd_config, 'empty static map definition for: %s', description) + ret.get_key = function(_, _) return nil end + ret.foreach = function(_, _) return true end + ret.on_load = function(_, cb) + rspamd_config:add_on_load(function(_, _, _) cb() end) + end + maps_cache[cache_key] = ret + return ret + end + if opt[1] then local function check_plain_map(line) return lua_util.str_startswith(line, 'http')