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

   Fixes [CAMEL-26501](https://issues.apache.org/jira/browse/CAMEL-26501).
   
   Follow-up of CAMEL-26069 (#28892) and CAMEL-26071 (#28894).
   
   ### What was wrong
   
   The `aws-bedrock-agent-runtime` operations that take the body as text 
(`retrieveAndGenerate`, `retrieve`, `invokeFlow`, `invokeAgent`, 
`invokeInlineAgent`) converted the body with the type converter. A `Map` body 
was sent as its `toString()`, such as `{question=what is camel?, limit=3}`, and 
a Jackson `JsonNode` as pretty-printed JSON (camel-jackson's converter). Since 
CAMEL-26069 the invoke operations of `aws-bedrock` marshal a `Map` or 
`JsonNode` body to JSON, so the two endpoints of the same component behaved 
differently.
   
   ### What changed
   
   - New `BedrockBodyHelper.jsonBody(Exchange)` in 
`org.apache.camel.component.aws2.bedrock`: a `Map` or `JsonNode` body 
marshalled to JSON, or null for another body. It is the code of 
`BedrockProducer.requestBody` from #28892, moved so both producers share it; 
`BedrockProducer` now calls it (same behaviour).
   - `BedrockAgentRuntimeProducer`: `resolveInputText` (invokeFlow, 
invokeAgent, invokeInlineAgent) and the query text of `retrieve` and 
`retrieveAndGenerate` use it. Other bodies are converted as before; a String 
body is unchanged.
   - `@BodyTypes` of the endpoint: `producerIn` lists `map`, and the 
description says a Map or JsonNode is sent as JSON text. Regenerated JSON and 
catalog copies.
   - Component doc: the body sections of retrieve, invokeFlow and invokeAgent.
   - Upgrade guide 4.24: a paragraph in the existing `camel-aws-bedrock` 
section.
   - `TextBodyFlowTest` (YAML validator): the `ask` route (`unmarshal: json` 
then `retrieveAndGenerate`) is no longer flagged, as the Map is now sent as 
JSON.
   
   ### Tests
   
   New tests in `BedrockAgentRuntimeProducerInvokeFlowTest`, 
`...InvokeAgentTest` and `...RetrieveTest` (Map and JsonNode bodies for all 
five operations, with a mocked client). The 6 new tests fail without the 
producer change (`{question=what is camel?, limit=3}` and pretty-printed JSON) 
and pass with it. Module: 181 unit tests pass, `-Psourcecheck` clean. 
`TextBodyFlowTest`: 85 pass against the regenerated catalog.
   
   ### Not changed
   
   - `invokeFlow` sends the JSON as a string `Document`, as the issue asks, not 
as an object `Document` built from the Map. A flow whose input node expects an 
object still needs a `FlowInput` body.
   - Other POJOs are still sent as their `toString()`, as before.
   
   _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