bhuvan-somisetty opened a new pull request, #14004: URL: https://github.com/apache/apisix/pull/14004
### Description In `apisix/plugins/tcp-logger.lua`, when `core.json.encode()` fails to serialize log entries, the callback was logging the error but proceeding to call `send_tcp_data(conf, nil)`. This resulted in `sock:send(nil)` throwing an unhandled Lua exception (`bad argument #1 to 'send' (string or table expected, got nil)`). This change: 1. Returns `false, 'error occurred while encoding the data: ' .. err` early when JSON serialization fails, aligning with `udp-logger` and `rocketmq-logger`. 2. Adds a colon separator to the socket initialization error message (`"failed to init the socket: " .. soc_err`). 3. Adds test coverage for JSON encoding failure handling in `t/plugin/tcp-logger.t`. #### Which issue(s) this PR fixes: Fixes #14003 ### Checklist - [x] I have explained the need for this PR and the problem it solves - [x] I have explained the changes or the new features added to this PR - [x] I have added tests corresponding to this change - [ ] I have updated the documentation to reflect this change - [x] I have verified that this change is backward compatible (If not, please discuss on the [APISIX mailing list](https://github.com/apache/apisix/tree/master#community) first) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
