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

   Second attempt. The [first one](https://github.com/apache/camel/pull/26831) 
threw, broke `RestProducerPathTest` in camel-core and was reverted in 
`7aec6a1a2b9b`. This one warns.
   
   A REST producer sends the request even when a path parameter has no value, 
so the call goes out with the placeholder still in it and the service answers 
404 for a path holding a `{name}`:
   
   ```
   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.
   
   Now:
   
   ```
   WARN  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. The request is sent 
with {sku} in the path,
         which the service is unlikely to answer. This is logged once per 
parameter.
   ```
   
   ### Why a warning and not a failure
   
   Both shapes are deliberate and each has a test that says so:
   
   - `testMissingHeader` — a partly resolved template keeps the rest of its 
placeholders and is sent. The comment reads *"Backward compatibility: if one of 
the params is resolved"*, matching the comment in `RestProducer`.
   - `testNoHeaders` — a template where nothing resolved is not an error 
either; it simply sets no `REST_HTTP_URI`.
   
   The second of those is exactly the shape this is about, so failing would 
contradict a documented behaviour rather than fix an oversight. That is what 
the first attempt did, and what the revert undid.
   
   ### Once per parameter
   
   A route missing a value is missing it for every message; the run this came 
from produced **2580** of these failures in a night. One warning per parameter 
per producer, not per message.
   
   ### Testing
   
   New `RestProducerUnresolvedPathWarnTest` (3 tests): it names the parameter 
**and the request is still sent with the placeholder** — that assertion is 
there so a future change cannot quietly turn this into a failure again; it is 
said once across three messages; and nothing is said when every parameter 
resolves.
   
   **The full camel-core suite passes: 7563 tests, 0 failures** — the step I 
skipped on the first attempt, where the broken test lived. `camel-rest` 129 
tests pass, `RestProducerPathTest` 11/11.
   
   The second half of CAMEL-24986, having the YAML validator say it before the 
route runs from the OpenAPI specification it already reads, is not in this PR.
   
   🤖 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