From: Vsevolod Stakhov Date: Thu, 2 Oct 2025 13:28:32 +0000 (+0100) Subject: [Fix] Add full Lua traceback to HTTP callback errors X-Git-Tag: 3.13.2~11^2~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=73f2d4cd178a065310e7d6c8a98141594cc85d27;p=thirdparty%2Frspamd.git [Fix] Add full Lua traceback to HTTP callback errors Improved error diagnostics in lua_http_finish_handler by adding rspamd_lua_traceback handler. Now shows complete call stack with file names and line numbers when Lua HTTP callbacks fail, making debugging much easier. --- diff --git a/src/lua/lua_http.c b/src/lua/lua_http.c index 24452f1715..3330bc6ea5 100644 --- a/src/lua/lua_http.c +++ b/src/lua/lua_http.c @@ -377,6 +377,9 @@ lua_http_finish_handler(struct rspamd_http_connection *conn, L = lcbd.L; + lua_pushcfunction(L, &rspamd_lua_traceback); + int err_idx = lua_gettop(L); + lua_rawgeti(L, LUA_REGISTRYINDEX, cbd->cbref); /* Error */ lua_pushnil(L); @@ -420,11 +423,13 @@ lua_http_finish_handler(struct rspamd_http_connection *conn, rspamd_symcache_set_cur_item(cbd->task, cbd->item); } - if (lua_pcall(L, 4, 0, 0) != 0) { + if (lua_pcall(L, 4, 0, err_idx) != 0) { msg_info("callback call failed: %s", lua_tostring(L, -1)); lua_pop(L, 1); } + lua_pop(L, 1); /* Remove traceback function */ + REF_RELEASE(cbd); lua_thread_pool_restore_callback(&lcbd);