WrightKD opened a new issue, #11646:
URL: https://github.com/apache/apisix/issues/11646
### Current Behavior
When using the body-transformer plugin - a small number of requests (~1%)
fail to transform the response body from xml to json. Strangely, most of the
requests work with the same template and route config from the same
source(upstream) .
### Expected Behavior
All requests succeed to transform the response body.
### Error Logs
Example Log Error
2024/10/12 18:20:37 [error] 53#53: *7177264 [lua] body-transformer.lua:158:
transform(): response template rendering: [string "context=... or {}..."]:10:
attempt to index field 'Body' (a nil value) while sending to client
2024/10/12 18:20:37 [error] 53#53: *7177264 [lua] body-transformer.lua:232:
phase_func(): failed to transform response body: <env:Envelope
xmlns:env="http://www.w3.org/2003/05/soap-envelope"><env:Header/><env:Body><m:NumberToWordsResponse
xmlns:m="http://www.dataaccess.com/webservicesserver/">
<m:NumberToWordsResult>ten thousand one hundred and eleven
</m:NumberToWordsResult> </m:NumberToWordsResponse></env:Body></env:Envelope>
### Steps to Reproduce
The difficult part of this issue is reproducing it. The issue occurs , not
always, after restarting the container used to run apisix (Image -
apisix:3.6.0-debian).
I currently restart the container when I notice the issue once a day, after
two - three restarts, the error seems to resolve itself , hence why it is hard
to reproduce the issue.
Notes in the investigation :
1. The error log - failed to transform response body - always has the
missing Body field (Envelope.Body) printed indicating that the response form
the upstream is fine.
2. Once the error starts, it breaks multiply routes that use the
body-transformer to transform XML to JSON. Not just a single route. Always on
the Body field (which is in the response as per Note 1 )
3. The request transform never throws an error for any route, the error only
occurs on the response transform.
4. While debugging and investigating the error, the template engine that is
used - resty.template - I can see that the Envelope in the xml response is
treated as a global variable.
5. There is routes that do not use the response transform and only the
request transform which work fine.
6. All errors seem to occur on the same thread/nginx work
List of plugins I have enabled :
{
"cors": true,
"opa": true,
"proxy-rewrite": true,
"loki-logger": true,
"response-rewrite": true,
"serverless-pre-function": true,
"access-auth": true,
"mocking": true,
"body-transformer": true,
"serverless-post-function": true,
"prometheus": true,
"file-logger": true,
"request-id": true
}
Any help would be appreciate.
### Environment
- APISIX version (run `apisix version`): 3.6.0
- Operating system (run `uname -a`): Linux e1ba353349de
5.15.153.1-microsoft-standard-WSL2 #1 SMP Fri Mar 29 23:14:13 UTC 2024 x86_64
GNU/Linux
- OpenResty / Nginx version (run `openresty -V` or `nginx -V`): nginx
version: openresty/1.21.4.2
- etcd version, if relevant (run `curl
http://127.0.0.1:9090/v1/server_info`): -
- APISIX Dashboard version, if relevant: -
- Plugin runner version, for issues related to plugin runners: -
- LuaRocks version, for installation issues (run `luarocks --version`): -
--
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]