Claus Ibsen created CAMEL-24910:
-----------------------------------
Summary: rest - a path parameter and an incoming HTTP header of
the same name are merged into a list, so a correct value fails
Key: CAMEL-24910
URL: https://issues.apache.org/jira/browse/CAMEL-24910
Project: Camel
Issue Type: Bug
Components: rest, camel-platform-http
Reporter: Claus Ibsen
Fix For: 4.23.0
A REST endpoint with a path parameter, {{/stock/{sku\}}}, sets the header
{{sku}} from the path. When the request also carries an HTTP header of that
name, the two are merged and the header becomes a {{List}}, so a route that
reads {{${header.sku\}}} gets {{[X, CAMEL-MUG]}} instead of a value. Reproduced
with the connect/http-client example of camel-jbang-examples (Camel
4.23.0-SNAPSHOT, platform-http on Vert.x):
{noformat}
$ curl -o /dev/null -w '%{http_code}' localhost:8080/stock/CAMEL-MUG
200
$ curl -o /dev/null -w '%{http_code}' -H 'sku: CAMEL-MUG'
localhost:8080/stock/CAMEL-MUG
404
$ curl -H 'sku: X' localhost:8080/stock/CAMEL-MUG
{"error": "unknown sku [X, CAMEL-MUG]"}
{noformat}
The value from the path is the one the route asked for and the one the contract
describes, so it should win; an incoming header of the same name should not
silently turn it into a list. Headers that do not clash ({{orderId}},
{{needed}}) are harmless.
Found in the camel-jbang-mcp stepwise benchmark: the local model set the line's
sku as a *header* rather than an exchange property, so its own HTTP call sent
{{sku}} along, and every call to its own service answered 404 with the list in
the message. The behaviour is a sharp edge for a person too: the error names a
list, which nothing in the route explains.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)