Skip to content

bug: APISIX incorrectly attempts to decompress uncompressed response bodies in log plugins #13093

@hachi029

Description

@hachi029

Current Behavior

When using a logging plugin to record the response body, APISIX attempts to decompress uncompressed data, causing warning messages in the error.log

Expected Behavior

APISIX only decompress compressed response bodies.

Error Logs

2026/03/17 09:17:47 [warn] 8028#8028: *41269 [lua] log-util.lua:417: collect_body(): try decode compressed data err: inflate gzip err: INFLATE: data error while sending to client, client: 127.0.0.1, server: _, request: "GET /file-logger HTTP/1.1", upstream: "http://127.0.0.1:9001/file-logger", host: "127.0.0.1:9080", request_id: "68725bcdd1aff0fad2f7a907daa9ac06"

Steps to Reproduce

  1. Run apisix with following router conf:
{
    "uri": "/file-logger",
    "upstream": {
        "nodes": {
            "127.0.0.1:9001": 1
        },
        "type": "roundrobin"
    },
    "id": "1"
    "plugins": {
        "file-logger": {
            "path": "logs/file.log",
            "include_resp_body":true
        },
        "gzip": {
            "types": ["application/json"],
            "min_length": 10,
            "compression_level": 5
        }
    }
}
  1. Start another nginx server 127.0.0.1:9001 with following conf :
location /file-logger {
        gzip off;
        content_by_lua_block {
            ngx.header.content_type = "application/json; charset=utf-8"
            ngx.say('{"code":"hello 123", "status":200}')
        }
 }
  1. Send request to APISIX:
curl -H 'Accept-Encoding: gzip' http://127.0.0.1:9080/file-logger

Environment

  • APISIX version (run apisix version): 3.15.0
  • Operating system (run uname -a): Linux 28d6b762434f 6.17.8-orbstack-00308-g8f9c941121b1 change: added doc of how to load plugin. #1 SMP PREEMPT Thu Nov 20 09:34:02 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
  • OpenResty / Nginx version (run openresty -V or nginx -V):
    nginx version: openresty/1.27.1.2
    built by gcc 13.3.0 (Ubuntu 13.3.0-6ubuntu2~24.04)
    built with OpenSSL 3.4.1 11 Feb 2025
    TLS SNI support enabled
    configure arguments: --prefix=/usr/local/openresty/nginx --with-debug --with-cc-opt='-DNGX_LUA_USE_ASSERT -DNGX_LUA_ABORT_AT_PANIC -O2 -DAPISIX_RUNTIME_VER=1.3.3 -DNGX_LUA_ABORT_AT_PANIC -I/usr/local/openresty/zlib/include -I/usr/local/openresty/pcre/include -I/usr/local/openresty/openssl3/include' --add-module=../ngx_devel_kit-0.3.3 --add-module=../echo-nginx-module-0.63 --add-module=../xss-nginx-module-0.06 --add-module=../ngx_coolkit-0.2 --add-module=../set-misc-nginx-module-0.33 --add-module=../form-input-nginx-module-0.12 --add-module=../encrypted-session-nginx-module-0.09 --add-module=../srcache-nginx-module-0.33 --add-module=../ngx_lua-0.10.28 --add-module=../ngx_lua_upstream-0.07 --add-module=../headers-more-nginx-module-0.37 --add-module=../array-var-nginx-module-0.06 --add-module=../memc-nginx-module-0.20 --add-module=../redis2-nginx-module-0.15 --add-module=../redis-nginx-module-0.3.9 --add-module=../ngx_stream_lua-0.0.16 --with-ld-opt='-Wl,-rpath,/usr/local/openresty/luajit/lib -Wl,-rpath,/usr/local/openresty/wasmtime-c-api/lib -L/usr/local/openresty/zlib/lib -L/usr/local/openresty/pcre/lib -L/usr/local/openresty/openssl3/lib -Wl,-rpath,/usr/local/openresty/zlib/lib:/usr/local/openresty/pcre/lib:/usr/local/openresty/openssl3/lib' --add-module=/tmp/tmp.jFWBmTCSbY/openresty-1.27.1.2/../mod_dubbo-1.0.2 --add-module=/tmp/tmp.jFWBmTCSbY/openresty-1.27.1.2/../ngx_multi_upstream_module-1.3.2 --add-module=/tmp/tmp.jFWBmTCSbY/openresty-1.27.1.2/../apisix-nginx-module-1.19.3 --add-module=/tmp/tmp.jFWBmTCSbY/openresty-1.27.1.2/../apisix-nginx-module-1.19.3/src/stream --add-module=/tmp/tmp.jFWBmTCSbY/openresty-1.27.1.2/../apisix-nginx-module-1.19.3/src/meta --add-module=/tmp/tmp.jFWBmTCSbY/openresty-1.27.1.2/../wasm-nginx-module-0.7.0 --add-module=/tmp/tmp.jFWBmTCSbY/openresty-1.27.1.2/../lua-var-nginx-module-v0.5.3 --add-module=/tmp/tmp.jFWBmTCSbY/openresty-1.27.1.2/../lua-resty-events-0.2.0 --with-poll_module --with-pcre-jit --with-stream --with-stream_ssl_module --with-stream_ssl_preread_module --with-http_v2_module --with-http_v3_module --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --with-http_stub_status_module --with-http_realip_module --with-http_addition_module --with-http_auth_request_module --with-http_secure_link_module --with-http_random_index_module --with-http_gzip_static_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-threads --with-compat --with-stream --with-http_ssl_module
  • 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):

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    📋 Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions