From: Vsevolod Stakhov Date: Tue, 18 Nov 2025 12:31:15 +0000 (+0000) Subject: [Fix] Make lua_shape :transform() tableshape-compatible X-Git-Tag: 3.14.1~11^2~18 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=51ea8cb73cae7439fd3dbda04a60d43a62798fc2;p=thirdparty%2Frspamd.git [Fix] Make lua_shape :transform() tableshape-compatible Change :transform() return values to match tableshape behavior: - Success: return value (not true, value) - Failure: return nil, error (not false, error) This is required for compatibility with lua_selectors check_args which expects the tableshape return convention. The :check() method still returns (bool, value_or_error) for new code. --- diff --git a/lualib/lua_shape/core.lua b/lualib/lua_shape/core.lua index 4ee1d32e54..667d26f206 100644 --- a/lualib/lua_shape/core.lua +++ b/lualib/lua_shape/core.lua @@ -81,9 +81,15 @@ local schema_methods = { end, -- Transform value according to schema + -- Returns: (value) on success, (nil, error) on failure (tableshape-compatible) transform = function(self, value, ctx) ctx = ctx or make_context("transform") - return self._check(self, value, ctx) + local ok, result = self._check(self, value, ctx) + if ok then + return result + else + return nil, result + end end, -- Make schema optional