davsclaus opened a new pull request, #26831:
URL: https://github.com/apache/camel/pull/26831

   A REST producer sent the request even when a path parameter had no value, so 
the call went out with the placeholder still in it:
   
   ```
   org.apache.camel.http.base.HttpOperationFailedException: HTTP operation 
failed invoking
   http://localhost:8080/api/stock/%7Bsku%7D/reserve with statusCode: 404
   ```
   
   `%7Bsku%7D` is `{sku}`. Nothing said the parameter was unresolved, so the 
reader sees a 404 and goes looking at the server.
   
   `RestProducer.resolvePlaceholders` reads a header, falls back to an exchange 
variable, and when neither has a value leaves the placeholder as it is — the 
request is sent anyway. `hasPath` is set only when at least one segment 
resolved, so a fully unresolved template falls through to the endpoint uri 
unchanged and a partly resolved one carries the rest into `REST_HTTP_URI`.
   
   After:
   
   ```
   The path parameter {sku} of /api/stock/{sku}/reserve has no value: set the 
header sku,
   or an exchange variable of that name, before the call.
   ```
   
   Only a name in the braces counts (letters, digits, `_`, `-`, `.`), so a uri 
holding braces for another reason is untouched.
   
   ### This changes behaviour
   
   `RestProducerAdvancedTest.testPrepareExchangeWithUnresolvedPlaceholder` 
pinned the old behaviour and is updated to assert the message. Worth a 
reviewer's judgement, so the context: that test arrived in *"(test): add 
quality test coverage for camel-rest component"*, and its comment (*"When 
placeholder is not resolved, REST_HTTP_URI should not be set"*) describes what 
happened rather than why it should. A request that still contains `{name}` 
cannot succeed against the service, so failing at the producer seemed more 
useful than a 404 from the far end — but if there is a case where the 
placeholder is meant to survive, this is the place to say so.
   
   I also considered pointing at `prepareUriTemplate=false` as an escape hatch 
and left it out: it is a producer setter with no URI option and no caller 
outside a test, so naming it would send people somewhere they cannot reach.
   
   ### How often it happens
   
   From an overnight local-model benchmark (22 examples, 5 passes, 360 steps): 
this one mistake produced **2580** of the runtime errors, the most of any 
single cause, and appeared in **13 of 15 runs** across the three HTTP examples. 
The route did set the header; the value never arrived, and nothing in the 
failure said so.
   
   The second half of CAMEL-24986 — having the YAML validator say it before the 
route runs, using the OpenAPI specification it already reads for CAMEL-24844 — 
is not in this PR.
   
   ### Testing
   
   `camel-rest` 129 tests and `camel-rest-openapi` 143 tests pass.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   
   https://claude.ai/code/session_01Bp3538HRBPMQkb5ta9xRaj


-- 
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]

Reply via email to