Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: When I turn on kafka-logger and body-transformer at the same time, the response body conversion of body-transformer plugin will fail. #11356

Open
FirstCatchYourHare opened this issue Jun 17, 2024 · 2 comments

Comments

@FirstCatchYourHare
Copy link

Current Behavior

When I turn on kafka-logger and body-transformer at the same time, the response body conversion of body-transformer plugin will fail. After turning off kafka-logger, body-transformer plug-in will fail

Expected Behavior

I hope that when I turn on kafka-logger and body-transformer at the same time, both will work properly at the same time

Error Logs

When I turn on kafka-logger and body-transformer at the same time,By tracking the source code log,I found that when the body-transformer plugin code went to body_filter, it got an empty response table, so the conversion failed, but the request was still successful, but no response body was returned

function M.body_filter(, ctx)
local conf = ctx.body_transformer_conf
if conf.response then
local body = core.response.hold_body_chunk(ctx)
core.log.error(cjson.encode(body))
if ngx.arg[2] == false and not body then
return
end

    local out = transform(conf, body, "response", ctx)
    if not out then
        core.log.error("failed to transform response body: ", body)
        return
    end

    ngx.arg[1] = out
end

end

Steps to Reproduce

1.Enable plug-ins kafka-logger and body-transformer at the same time
2.The upstream service is a webservice
3.By configuring body-transformer, you mainly convert the xml response body to the json response body

Environment

  • APISIX version (run apisix version):apache/apisix-3.2.0-debian
  • Operating system (run uname -a):Linux new 3.10.0-1127.el7.x86_64 change: added doc of how to load plugin. #1 SMP Tue Mar 31 23:36:51 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
  • OpenResty / Nginx version (run openresty -V or nginx -V):nginx version: openresty/1.21.4.1
  • etcd version, if relevant (run curl http://127.0.0.1:9090/v1/server_info):3.5.0
  • APISIX Dashboard version, if relevant:apache/apisix-dashboard 3.0.0-alpine
  • Plugin runner version, for issues related to plugin runners:
  • LuaRocks version, for installation issues (run luarocks --version):
@FirstCatchYourHare
Copy link
Author

Suddenly think of it, it may be the reason why the http response body can not be read twice

@FirstCatchYourHare
Copy link
Author

this bug is resolved at apisix3.2.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 📋 Backlog
Development

No branches or pull requests

1 participant