apache / apache/shenyu

[BUG] WebClient request-header deduplication is a no-op (feature broken on the WebClient path)

Open Beginner friendly
#6,543 1 comment 0 reactions 0 assignees View on GitHub
plugin: http-client priority: high type: bug
Dominant language
Java
Stars
8.8k
Forks
3.1k
Avg merge
7d 1h
Merged PRs (30d)
85

Description

## Description
`doRequest` builds a deduplicated copy of the request headers (`httpHeaders`, lines 62-63) via `duplicateHeaders(..., REQ_UNIQUE_HEADER)`. But the outbound request is then populated from `exchange.getRequest().getHeaders()` — the **original, non-deduplicated** headers — via `headers.addAll(exchange.getRequest().getHeaders())` (line 67). The `httpHeaders` variable is computed and thrown away; it is never used to build the request. The sibling `NettyHttpClientPlugin.java:72` correctly applies the deduped copy via `httpHeaders.forEach(headers::set)`.

## Location
```
shenyu-plugin-httpclient/.../WebClientPlugin.java:62-67
NettyHttpClientPlugin.java:72 (correct)
```

## Impact
The "unique header" feature is silently inactive on the WebClient path while it works on the Netty path — inconsistent behavior depending on which HTTP client is configured. Upstream servers that reject duplicate headers (or pick the wrong value) will misbehave, and the configured retain-first/last/unique policy is ignored.

## Suggested fix
In the `WebClientPlugin` headers lambda, replace `headers.addAll(exchange.getRequest().getHeaders())` with `httpHeaders.forEach(headers::set)` (mirroring `NettyHttpClientPlugin`).

## Related existing issue(s)
#6255/#6254 (closed) were about request-template custom headers; this is the dedup result being discarded entirely, distinct.

_Identified during the 2026-08-02 audit; full list in [`docs/issue-candidates-2026-08-02.md`](docs/issue-candidates-2026-08-02.md)._

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in shenyu-plugin-httpclient/.../WebClientPlugin.java at doRequest and inspect lines 62-67, then compare the header handling with NettyHttpClientPlugin.java:72. Verify that the deduplicated httpHeaders result is used for the outbound WebClient request and that the configured retain-first/last/unique policy is no longer discarded.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, backend
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.