bhuvan-somisetty opened a new pull request, #14012:
URL: https://github.com/apache/apisix/pull/14012

   ### Description
   
   In `apisix/plugins/splunk-hec-logging.lua`, `send_to_splunk` handles non-200 
responses by decoding JSON and concatenating `body.text`. When Splunk HEC or an 
intermediate reverse proxy / API gateway returns an error response with JSON 
that lacks the `text` attribute (such as `{"message": "Unauthorized"}` or 
`{"error": "Forbidden"}`), `body.text` evaluates to `nil`. This triggers a Lua 
runtime error: `attempt to concatenate field 'text' (a nil value)`, causing the 
batch processor timer to crash.
   
   This PR updates `send_to_splunk` to safely extract error information by 
checking `body.text or body.message`, falling back to `res.body`, and finally 
falling back to the HTTP status code.
   
   #### Which issue(s) this PR fixes:
   
   Fixes #14011
   
   ### 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]

Reply via email to