CAMEL-24324: camel-aws-bedrock - throw when pojoRequest=true and the body is the wrong type - #25278
Conversation
…body is the wrong type Child of CAMEL-24261. Most BedrockAgent/BedrockAgentRuntime operations already fail fast on a wrong POJO body, but four did not: startIngestionJob, listIngestionJobs, getIngestionJob (BedrockAgentProducer) and retrieveAndGenerate (BedrockAgentRuntimeProducer) silently fell through with no AWS call and no error. Add the missing else that throws IllegalArgumentException, matching the wording already used by the sibling operations in the same module. BedrockProducer (runtime) is already covered by CAMEL-23462. Covered by two new Mockito-based unit tests (the module has no producer route harness); each was verified to fail (silent no-op) before the fix. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Andrea Cosentino <ancosen@gmail.com>
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
|
🧪 CI tested the following changed modules:
🔬 Scalpel shadow comparison — Scalpel: 9 tested, 29 compile-only — current: 9 all testedMaveniverse Scalpel detected 38 affected modules (current approach: 9).
|
gnodet
left a comment
There was a problem hiding this comment.
Clean, well-scoped fix that adds missing else branches to throw IllegalArgumentException when pojoRequest=true and the body is the wrong type for four Bedrock Agent/AgentRuntime operations that previously silently did nothing. Tests are well-written and follow project conventions.
Highlights:
- The fix correctly mirrors the pattern already established by the
retrieveandinvokeFlowoperations in the sameBedrockAgentRuntimeProducerclass. Error message wording is consistent across all agent/agentruntime operations. - Tests properly use AssertJ assertions and package-private visibility, following project conventions.
- The parameterized test approach for the three agent operations is a nice touch, reducing boilerplate.
Minor nit (non-blocking): Each parameterized test invocation creates a new DefaultCamelContext without closing it. While the context is never started and this is a lightweight unit test, wrapping in try-with-resources would be slightly cleaner for resource hygiene.
Claude Code on behalf of Guillaume Nodet
Child of CAMEL-24261 (completing CAMEL-23462 across the AWS2 producers).
Problem
Most
BedrockAgent/BedrockAgentRuntimeoperations already fail fast whenpojoRequest=trueand the body is not the expected request type. Four did not —they fell through the
instanceofwith noelse, so no AWS call was made, noresponse was set, and the original body was returned with no error:
BedrockAgentProducer:startIngestionJob,listIngestionJobs,getIngestionJobBedrockAgentRuntimeProducer:retrieveAndGenerate(
BedrockProducerin the runtime package is already covered by CAMEL-23462.)Fix
Each of the four branches now throws
IllegalArgumentException, matching thewording the sibling operations in the same module already use, e.g.
"retrieveAndGenerate operation requires a RetrieveAndGenerateRequest body when pojoRequest=true".Tests
camel-aws-bedrockhas no producer route/mock harness, so this is covered by twonew Mockito unit tests that mock the endpoint + client, send a wrong-typed body
with
pojoRequest=true, and assert theIllegalArgumentException. Each wasverified to fail (silent no-op) before the fix. Region-free — no localstack or
real AWS.
Docs / backport
The shared 4.22 upgrade-guide entry was added with CAMEL-24263. Main only, matching
the CAMEL-23462 precedent (behaviour change, shipped in a minor, not backported).
Claude Code on behalf of oscerd