This is an automated email from the ASF dual-hosted git repository.
LiteSun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git
The following commit(s) were added to refs/heads/master by this push:
new 7f7b7a0ba fix(syslog): return early when logger init fails (#13970)
7f7b7a0ba is described below
commit 7f7b7a0ba8adadd2e9a937ae8839ad8fa28639e7
Author: Bhuvan Somisetty <[email protected]>
AuthorDate: Thu Nov 5 20:01:07 2026 +0530
fix(syslog): return early when logger init fails (#13970)
---
apisix/plugins/syslog/init.lua | 1 +
t/plugin/syslog.t | 20 +++++++++++++++++++-
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/apisix/plugins/syslog/init.lua b/apisix/plugins/syslog/init.lua
index d80307cc0..26679867d 100644
--- a/apisix/plugins/syslog/init.lua
+++ b/apisix/plugins/syslog/init.lua
@@ -65,6 +65,7 @@ local function send_syslog_data(conf, log_message, api_ctx)
if not logger then
res = false
err_msg = "failed when initiating the sys logger processor: " .. err
+ return res, err_msg
end
-- reuse the logger object
diff --git a/t/plugin/syslog.t b/t/plugin/syslog.t
index 451a26d1b..8e7f45ab8 100644
--- a/t/plugin/syslog.t
+++ b/t/plugin/syslog.t
@@ -690,7 +690,7 @@ GET /t
-=== TEST 22: add syslog plugin for the send failure test
+=== TEST 22: add syslog plugin for the failure tests
--- config
location /t {
content_by_lua_block {
@@ -746,3 +746,21 @@ hello world
--- wait: 0.5
--- error_log
failed to log message: mocked send failure
+
+
+
+=== TEST 24: hit route, logger init failure is reported instead of crashing
+--- extra_init_by_lua
+ local logger_socket = require("resty.logger.socket")
+ logger_socket.new = function()
+ return nil, "mocked connection failure"
+ end
+--- request
+GET /hello
+--- response_body
+hello world
+--- wait: 0.5
+--- error_log
+failed when initiating the sys logger processor: mocked connection failure
+--- no_error_log
+attempt to index