[Rspamd-Users] Ok another one...

Lucas Rolff lucas at lucasrolff.com
Sun Sep 14 05:38:13 UTC 2025


Arg #1 in get_upstream_by_hash is the `key` (`redis_key`) in your case.
So whatever that value is set to, seems like a table and not a string.

> On 14 Sep 2025, at 01:08, Michelle Sullivan <michelle at isux.com> wrote:
> 
> 
> 
>> On 14 Sep 2025, at 07:44, Michelle Sullivan <michelle at isux.com> wrote:
>> 
>> 
>> 
>>> On 14 Sep 2025, at 01:29, Vsevolod Stakhov <vsevolod at rspamd.com> wrote:
>>> 
>>> On 13/09/2025 15:30, Michelle Sullivan wrote:
>>>> PD_FROM_CHECK is my module.. but there is also the issue with the bayes module so I am leaning it’s a config issue…
>>> 
>>> Yes, you can fuck up all other modules in your own module easily - that's how Lua stack works. But please don't blame those modules - it's not their fault.
>> 
>> 
>> Wasn’t trying to blame the other modules… was thinking it was me screwing up the Redis config somehow… and sure enough disabling my module and the bayes error goes away..  That’s a tad troubling for me… seems fragile.
>> 
> 
> 
> FWIW latest round of errors is:
> 
> Sep 14 09:01:11 thunderhawk rspamd[57571]: <cm83dz>; lua; pd_from_check.lua:63: pd_from_check setting key: rs_frmchk-a4uyknxd81yp185mm5j9
> Sep 14 09:01:11 thunderhawk rspamd[57571]: <cm83dz>; lua; pd_from_check.lua:74: pd_from_check redis_params: {[hash] = w7i56pp8ok4fg3dwniwwsn87dcnqdm7esmmdj1pmde41ta5ssho4cgyy57sf18as949qgd1hmsfam3xj7a65hrckotidosjnm6pjyqb, [expand_keys] = false, [write_servers] = rspamd{upstream_list}(00000008B5B3F138), [read_only] = false, [read_servers_str] = 192.168.250.2, [db] = 0, [timeout] = 1, [write_servers_str] = 192.168.250.2, [read_servers] = rspamd{upstream_list}(00000008B5B08748)}
> Sep 14 09:01:11 thunderhawk rspamd[57571]: <c954d9>; csession; lua_metric_symbol_callback: call to (PD_FROM_CHECK) failed (2): /usr/local/share/rspamd/lualib/lua_redis.lua:973: bad argument #1 to 'get_upstream_by_hash' (string expected, got table); trace: [1]:{[C]:-1 - get_upstream_by_hash [C]}; [2]:{/usr/local/share/rspamd/lualib/lua_redis.lua:973 - redis_make_request [Lua]}; [3]:{/etc/rspamd/lua.local.d/pd_from_check.lua:75 - pd_check_redis [Lua]}; [4]:{/etc/rspamd/lua.local.d/pd_from_check.lua:123 - <unknown> [Lua]};
> 
> The code is quite simple line 66 on:
> 
>  local function redis_frmchk_cb(err, data)
>    if err then
>      rspamd_logger.warnx(task, 'cannot get reply from Redis: %s', err)
>    else
>      rspamd_logger.warnx(task, 'got reply from Redis: %s', data)
>    end
>  end
> 
>  rspamd_logger.warnx(rspamd_config, '%s redis_params: %s', N, redis_params)
>  ret = lua_redis.redis_make_request(task,
>    redis_params, -- connect params
>    {redis_key},
>    true, -- is write
>    redis_frmchk_cb, --callback
>    'SADD', -- command
>    {redis_name}
>  )
>  if not ret then
>    rspamd_logger.warnx(task, 'cannot make SADD request to Redis; email %s', email)
>    return false
>  end
> 
> Down the bottom I have:
> 
> redis_params = lua_redis.parse_redis_server(N, settings)
> 
> if settings and settings.enabled == false then
>  rspamd_logger.warnx(rspamd_config, '%s is disabled', N)
>  return
> end
> 
> if not redis_params then
>  rspamd_logger.infox(rspamd_config, 'no servers are specified, disabling module')
>  rspamd_lua_utils.disable_module(N, "redis")
> else
>  lua_redis.register_prefix(settings.redis_prefix .. '-[a-z0-9]{20}', N,
>      'From address elements (hashes)"', {
>                  type = 'string',
>                          })
>  rspamd_logger.warnx(rspamd_config, '%s registering symbol %s...', N, settings.symbol)
>  rspamd_config:register_symbol{
> 
> And at the top to declare:
> 
> local fun = require "fun"
> local rspamd_logger = require "rspamd_logger"
> local lua_redis = require "lua_redis"
> local lua_util = require "lua_util"
> local hash = require "rspamd_cryptobox_hash"
> local ts = (require "tableshape").types
> local redis_params
> 
> local N = 'pd_from_check'  -- Namespace for logging
> rspamd_logger.warnx(rspamd_config, '%s boot..', N)
> 
> local settings = {
>  redis_prefix = 'rs_frmchk',
>  redis_min_expiry = 24 * 3600,
>  symbol = 'PD_FROM_CHECK',
>  score = 0.0,
>  weight = 0.0,
>  soft_threshold = 3,
>  soft_action = "",
>  medium_threshold = 5,
>  medium_action = "add-header",
>  hard_limit = 7,
>  hard_action = "reject",
>  one_shot = false,
> }
> 
> I don’t get any errors until I attempt to test the Redis part - everything else works fine…
> 
> *stumped*
> 
> Michelle
> 
> 
>> 
>>> -- 
>>> Users mailing list
>>> Users at lists.rspamd.com
>>> https://lists.rspamd.com/mailman/listinfo/users
>> 
>> -- 
>> Users mailing list
>> Users at lists.rspamd.com
>> https://lists.rspamd.com/mailman/listinfo/users
> 
> -- 
> Users mailing list
> Users at lists.rspamd.com
> https://lists.rspamd.com/mailman/listinfo/users



More information about the Users mailing list