Use math.floor() to convert batch_size to integer before using in loops.
Fractional values like 1.5 would cause batch_start (e.g. 2.5) to index
results[] with non-integer, returning nil and crashing prepare_report()
with 'string expected, got nil'.
local opts = parser:parse(args)
- -- Normalize batch_size to prevent invalid values (0 or negative) breaking loops
- opts.batch_size = math.max(1, opts.batch_size or 10)
+ -- Normalize batch_size: floor to integer and clamp to >= 1
+ -- Fractional values would break array indexing in batching loops
+ opts.batch_size = math.max(1, math.floor(opts.batch_size or 10))
pool = rspamd_mempool.create()
load_config(opts)