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

   ## What this PR does
   
   Fixes [CAMEL-23462](https://issues.apache.org/jira/browse/CAMEL-23462).
   
   The `invokeTextModel`, `invokeImageModel`, and `invokeEmbeddingsModel` 
operations in `BedrockProducer` only acted when `pojoRequest=true` **and** the 
message body was an `InvokeModelRequest`. For any other body type (e.g. 
`String`, `Map`), the `if (payload instanceof InvokeModelRequest ...)` block 
was skipped with no `else`, so the producer returned silently — leaving the 
caller with a `null` body and no indication of what went wrong.
   
   The `converse`, `converseStream`, and `applyGuardrail` operations already 
throw an `IllegalArgumentException` for the same misconfiguration. This PR 
makes the invoke operations consistent.
   
   ## Changes
   
   - **`BedrockProducer`**: add an `else throw new 
IllegalArgumentException(...)` branch to:
     - `invokeTextModel`
     - `invokeImageModel`
     - `invokeEmbeddingsModel`
     - `invokeTextModelStreaming` — the same silent no-op existed on the 
streaming path; this also covers `invokeImageModelStreaming` and 
`invokeEmbeddingsModelStreaming`, which delegate to it.
   - **New `BedrockInvokeModelPojoRequestTest`**: 5 mock-based unit tests (no 
AWS credentials / network) verifying each operation fails fast with the 
expected `IllegalArgumentException` type and message when given a wrong-type 
POJO body. The exception is raised before any client call, so a mocked client 
suffices.
   
   ## Behaviour change
   
   | | Before | After |
   |---|--------|-------|
   | Wrong-type body, `pojoRequest=true` | silent `null` output, no error | 
`IllegalArgumentException` naming the required body type |
   
   This only affects already-broken/misconfigured routes (a wrong body type 
produced no usable output before). No default, option, header, or public API 
signature changes, so no upgrade-guide entry is required.
   
   ## Testing
   
   `mvn clean install -Psourcecheck` in 
`components/camel-aws/camel-aws-bedrock` → **BUILD SUCCESS**, 122 tests pass 
(including the 5 new ones), formatter/impsort clean.
   
   ---
   _Claude Code on behalf of Andrea Cosentino._
   
   🤖 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