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

   Fixes [CAMEL-26263](https://issues.apache.org/jira/browse/CAMEL-26263).
   
   ### 1. `dapr:secret` always failed
   
   `DaprOperationManager` registered a handler for every operation except 
`secret`, so every `dapr:secret` call failed with 
`UnsupportedOperationException: No handler for operation secret`. The existing 
`DaprSecretTest` calls `DaprSecretHandler` directly, so it passed.
   
   Change: register `DaprSecretHandler` for `DaprOperation.secret`.
   
   ### 2. The producer replaced all message headers
   
   `DaprProducer.setResponse` called `setHeaders(response.getHeaders())`, so 
every header set before the call was gone afterwards. For operations whose 
response has a `Map.of(...)` of headers (configuration, some workflow 
operations), the message headers also became that immutable map.
   
   Change: keep the message headers and `putAll` the response headers.
   
   ### 3. A stream body failed, and a text body was sent as a JSON string
   
   The `invokeService`, `pubSub`, `invokeBinding` and `state` `save` handlers 
gave `getIn().getBody()` as is to the `DaprClient`. Its serializer sends 
`byte[]` as is and serializes everything else with Jackson, so `hello` was sent 
as `"hello"` (with the quotes), a JSON text was sent as a quoted, escaped 
string, and an `InputStream` failed.
   
   Change: a new `DaprOperationHandler.getPayload(Exchange)` converts a 
`String`, `InputStream`, `Reader` or `StreamCache` body to `byte[]` (with the 
exchange charset). Other bodies (`byte[]`, `Map`, POJO, ...) are given to the 
client as before. The `State` returned by `state` `save` now holds the bytes 
that were saved.
   
   ### Tests
   
   New `DaprProducerTest` goes through the endpoint with mocked Dapr clients: 
key and bulk secret, headers kept plus the response header (and the headers can 
still be changed afterwards), text and stream bodies sent as bytes for 
invokeService, pubSub, invokeBinding and state save, and a `Map` body still 
given as is. 8 of its 9 tests fail without the fix (the `Map` one is a guard). 
`DaprStateTest.testSave` now expects the saved bytes. Module: 82 tests, all 
pass.
   
   ### Docs and generated files
   
   - `@BodyTypes` producer-in text of the endpoint updated (it described the 
old behaviour) and `stream` added; `dapr.json` regenerated and copied to the 
catalog.
   - Component page: a short paragraph on the headers and the message body; 
catalog copy updated.
   - Upgrade guide 4.24: a `camel-dapr` entry for the kept headers and the 
text/stream bodies.
   
   ### Not changed
   
   - The workflow operations (`scheduleNew`, `terminate`, `raiseEvent`) still 
give the body as is to the workflow client. It serializes with its own data 
converter for the typed input of the workflow, so a `String` input is valid 
there, and `byte[]` would arrive as base64.
   - The doc examples that publish or save a constant `String` keep working; 
the data is now sent as the text itself.
   
   ### Open question
   
   Behaviour change: a route that relied on a `String` body being sent as a 
quoted JSON string now gets the raw text. The upgrade guide says so; this 
follows the proposal in the issue.
   
   _Claude Code on behalf of Claus Ibsen (davsclaus)_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


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