janiussyafiq opened a new issue, #13163:
URL: https://github.com/apache/apisix/issues/13163
### Current Behavior
When configuring `headers.add` in the `proxy-rewrite` plugin with multiple
values for the same header name, only the last value is forwarded to upstream.
All earlier values are silently dropped with no warning, error log, or
validation message.
This is caused by a fundamental JSON limitation: duplicate keys in an object
are undefined behavior by spec. In practice, Lua's cjson parser (used by
APISIX/OpenResty) only retains the last occurrence of a duplicate key when
deserializing the plugin config.
For example, the following config:
```json
"headers": {
"add": {
"foo": "bar2",
"foo": "bar3"
}
}
```
Results in only foo: bar3 being added. The value bar2 is lost entirely at
config parsing time, before the plugin even executes.
### Expected Behavior
Either:
1. The schema should support multi-value headers via an array syntax, e.g.
"foo": ["bar1", "bar2"], so users can express the intent without relying on
duplicate JSON keys.
2. Or, the admin API should reject configs with duplicate keys and return a
validation error, rather than silently accepting and dropping values.
### Error Logs
No error logs are produced.
### Steps to Reproduce
1. Create a route with the following config:
```bash
curl -X PUT 'http://127.0.0.1:9180/apisix/admin/routes/1' \
-H 'X-API-KEY: <admin_key>' \
-H 'Content-Type: application/json' \
-d '{
"uri": "/anything",
"plugins": {
"proxy-rewrite": {
"headers": {
"add": {
"foo": "bar2",
"foo": "bar3"
}
}
}
},
"upstream": {
"type": "roundrobin",
"nodes": { "httpbin.org:80": 1 }
}
}'
```
2. Send a test request:
```bash
curl -X GET -H 'foo: bar1' 'http://127.0.0.1:9080/anything'
```
3. Observe the echoed headers in the response — only foo: bar3 is present.
foo: bar2 is missing with no error.
```bash
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 423
Connection: keep-alive
Date: Mon, 06 Apr 2026 04:09:23 GMT
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Server: APISIX/3.15.0
{
"args": {},
"data": "",
"files": {},
"form": {},
"headers": {
"Accept": "*/*",
"Foo": "bar1,bar3",
"Host": "127.0.0.1",
"User-Agent": "curl/7.81.0",
"X-Amzn-Trace-Id": "<redacted>",
"X-Forwarded-Host": "127.0.0.1:9080"
},
"json": null,
"method": "GET",
"origin": "127.0.0.1, <redacted>",
"url": "http://127.0.0.1:9080/anything"
}
```
### Environment
- APISIX version (run `apisix version`): 3.15.0
- Operating system (run `uname -a`): Ubuntu
- OpenResty / Nginx version (run `openresty -V` or `nginx -V`):
- 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]