[BUG] Request plugin add* operations overwrite existing values like set*
Is there an existing issue for this?
- [x] I have searched the existing issues
Current Behavior
In the Request plugin, addParameters, addHeaders, and addCookies behave the same as their corresponding set* operations when the target key already exists.
For example, when the original request contains:
?tag=old
and the Request plugin is configured with:
{
"parameter": {
"addParameters": {
"tag": "new"
}
}
}
the downstream service receives:
tag=new
instead of preserving the original value.
The current implementation routes both add* and set* operations through the same logic based on set(), resulting in identical behavior.
Expected Behavior
add* operations should preserve existing values and append the configured value, while set* operations should continue to overwrite existing values.
Example:
Original request:
?tag=old
addParameters(tag=new)
Expected:
tag=old&tag=new
or an equivalent multi-value representation.
The same semantic distinction should apply to headers and cookies.
Steps To Reproduce
-
Enable the Request plugin.
-
Configure a Request plugin rule:
{
"parameter": {
"addParameters": {
"tag": "new"
}
}
}
- Send a request containing an existing query parameter:
curl "http://localhost:9195/http/request-bug/echo?tag=old"
- Observe that the downstream service receives:
tag=new
instead of preserving the original value and appending the new value.
Environment
ShenYu version: 2.4.0
Apache ShenYu master branch
Module: shenyu-plugin-request
Local standalone deployment
Debug logs
RequestHandle documents addHeaders as "need to be appended new header value", while setHeaders is documented as covering/overwriting the value.
ModifyResponsePlugin also implements:
addHeaders -> HttpHeaders.add(...) setHeaders -> HttpHeaders.set(...)
which suggests that add and set are intended to have different semantics.
Anything else?
I would be happy to work on a PR if this behavior is confirmed as a bugπ.
π Hello @yuluo-yx
A new issue has been opened by @SouthwestAsiaFloat:
- Title: [BUG] Request plugin add* operations overwrite existing values like set*
- Link: https://github.com/apache/shenyu/issues/6360
Please review when you have time. Thank you! π
hi, thanks for your issue report, can you fix this?
hi, thanks for your issue report, can you fix this?
I would like to fix itπ
hi, thanks for your issue report, can you fix this?
I would like to fix itπ
okay, glad to hear. just submit a pr , and i will review