Skip to content

fix(syslog): return early when logger init fails - #13970

Open
bhuvan-somisetty wants to merge 1 commit into
apache:masterfrom
bhuvan-somisetty:fix/syslog-nil-logger-crash
Open

bhuvan-somisetty wants to merge 1 commit into
apache:masterfrom
bhuvan-somisetty:fix/syslog-nil-logger-crash

Conversation

@bhuvan-somisetty

@bhuvan-somisetty bhuvan-somisetty commented Sep 17, 2026

Copy link
Copy Markdown

Description

send_syslog_data() in apisix/plugins/syslog/init.lua fetches the logger instance from the lrucache and correctly checks whether it failed:

if not logger then
res = false
err_msg = "failed when initiating the sys logger processor".. err
end

When logger_socket.new(...) fails, for example due to a bad host or port or a socket error, logger is nil and this branch correctly builds an error message, but it never returns. Execution falls through to the very next line, logger:log(log_message), which indexes a nil value. This throws an uncaught Lua runtime error inside the log phase batch processor callback instead of returning the already built false, err_msg back to the caller, the same way the function already does for the logger:log() failure case right below it.

This PR adds the missing return so a failed logger init is reported as a clean batch processor error instead of crashing the log phase.

Which issue(s) this PR fixes:

Fixes #13969

Checklist

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
  • I have updated the documentation to reflect this change (no user facing docs needed for this internal bug fix)
  • I have verified that this change is backward compatible

send_syslog_data detected a failed logger init but fell through to
logger:log(log_message) on the next line, indexing a nil value and
crashing the log phase instead of returning the already built error.

Fixes apache#13969
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: syslog plugin crashes with nil-index error instead of returning an error when logger init fails

1 participant