bug: # APISIX 3.16 → 3.17 Chunked POST Regression
Current Behavior
Summary
Chunked-Transfer-Encoding POST requests are rejected with 413 Request Entity Too Large
by apache/apisix:3.17.0-redhat, while the identical request against
apache/apisix:3.16.0-redhat succeeds. Requests using a Content-Length header (no
chunked encoding) work correctly on both versions.
Expected Behavior
Chunked-Transfer-Encoding POST requests are working like before.
Error Logs
No response
Steps to Reproduce
This was reproduced in a k3d (Kubernetes) cluster with both images running side-by-side with byte-for-byte identical APISIX route configuration — the only variable was the container image tag.
Environment
- k3d v5.9.0 cluster (
apisix-test), local registry atapisix-registry:5000 - APISIX deployed in standalone mode (
config_provider: yaml, no etcd) so both versions run from an identicalapisix.yaml/config.yaml - Upstream:
mendhak/http-https-echo:31, echoes back method/headers/body as JSON - Route:
uri: /*→echo-upstream.apisix-test.svc.cluster.local:80 - Manifests:
k8s/namespace.yaml,k8s/apisix-configmap.yaml,k8s/echo-upstream.yaml,k8s/apisix-v316.yaml,k8s/apisix-v317.yaml
The nginx core jump from 1.27 → 1.29 changed how the chunked-body-size accounting
path treats a client_max_body_size of 0: for standard (Content-Length) requests the
"0 disables the check" special case still applies, but for chunked request bodies the
newer core enforces the limit literally (0 allowed bytes), rejecting the very first chunk
regardless of size. This is why the failure is specific to chunked requests and appears
immediately after the 3.16→3.17 upgrade with no config change on the user's side.
Hi @mcupei, thanks for the issue. I've reproduced this bug and it is caused by a rebase mistake at api7/apisix-nginx-module repository.
Root cause
APISIX 3.17 bumped the runtime base from OpenResty 1.27.1.2 to 1.29.2.4. While porting the patches to the new base, the && max_body_size zero-guard was lost in patch/1.29.2.4/nginx-client_max_body_size.patch (hunk for ngx_http_request_body_chunked_filter()):
/* old patch — correct */ /* new patch — guard lost */
if (max_body_size if (max_body_size
&& max_body_size - r->headers_in.content_length_n < rb->chunked->size)
- r->headers_in.content_length_n < rb->chunked->size)
Since APISIX defaults to client_max_body_size 0 (unlimited), the check becomes 0 - 0 < chunk_size → always true → 413 for every HTTP/1.1 chunked request, regardless of size. Requests with Content-Length take a different code path whose guard is intact, which is why only chunked requests fail.
The fix is already proposed in api7/apisix-nginx-module#115. After it's merged, a new apisix-runtime release and rebuilt 3.17.x images are still needed.
Workaround
Until a fixed image is released, set any non-zero limit in config.yaml (verified on 3.17.0):
nginx_config:
http:
client_max_body_size: 1000m
Additional reproduction (production, K3s + APISIX Ingress)
Same regression as this issue. Confirmed it is not an actually-oversized body.
Environment
- APISIX on K3s (Ingress Controller), TLS terminated at APISIX
nginx.confhasclient_max_body_size 0;(unlimited, default)- HTTP/1.1 POST from a Spring
RestTemplatewebhook client - Route: third-party callback
POST /callback/...→ HTTP upstream
Access log (redacted)
... "POST /callback_api/... HTTP/1.1" 413 255 0.018 "-" "" - - -
upstream_addr / upstream_status / upstream_response_time are all - → rejected in APISIX, never forwarded.
Error log (redacted)
client intended to send too large chunked body: 0+311 bytes, ... request: "POST /callback/... HTTP/1.1", host: "xxx.xxx.com"
First chunk is only 311 bytes. The 0+ matches client_max_body_size 0 treated as a literal 0-byte quota on the chunked path.
Temporary workaround
Leaving the global limit at 0 still 413s any non-empty chunked POST. Setting a non-zero limit unblocks it.
Option A (what we used): route-level client-control — ApisixRoute / Admin API, no APISIX restart:
plugins:
- name: client-control
enable: true
config:
max_body_size: 10485760 # 10MiB; must be != 0
After this, the same webhook returned 200 and upstream_* was populated.
Option B (global, as in this issue): non-zero client_max_body_size — requires rendering nginx.conf and restarting APISIX:
nginx_config:
http:
client_max_body_size: 100m # must be != 0; do not use 0
We prefer A until a runtime image that includes api7/apisix-nginx-module#115 is available.
Question
Which released APISIX / apisix-runtime image includes api7/apisix-nginx-module#115 so we can drop the route workaround?