CAMEL-24326: camel-aws-config - throw when pojoRequest=true and the body is the wrong type - #25305
Conversation
…ody is the wrong type Child of CAMEL-24261. AWSConfigProducer's five operations (putConfigRule, removeConfigRule, describeRuleCompliance, putConformancePack, removeConformancePack) only acted when the body was the matching request type under pojoRequest=true; any other body silently fell through with no AWS call and no error. Add the missing else that throws IllegalArgumentException naming the required type, consistent with CAMEL-23462. Covered by a new Mockito-based parameterized unit test (the module has no producer route harness); verified to fail (silent no-op) before the fix. The shared 4.22 upgrade-guide entry was added with CAMEL-24263. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Andrea Cosentino <ancosen@gmail.com>
gnodet
left a comment
There was a problem hiding this comment.
This review was generated by Claude Code, an AI assistant, on behalf of @gnodet.
Clean and well-structured PR. The validation logic, exception type, and error message format are all consistent with the precedent set by BedrockProducer under the parent issue CAMEL-24261.
What I verified:
- All 5 operation methods (
putConfigRule,removeConfigRule,describeRuleCompliance,putConformancePack,removeConformancePack) now haveelsebranches that throwIllegalArgumentExceptionwhenpojoRequest=trueand the body is not the expected SDK request type. IllegalArgumentExceptionis already the validation exception used throughoutAWSConfigProducer(lines 70, 121, 165, 235, 250, 287), so this is consistent.- Error message format (
<operation> operation requires <SdkType> in POJO mode) matches the bedrock component. - The test uses package-private visibility (JUnit 5 convention), AssertJ assertions (project convention), and a parameterized
@CsvSourcecovering all 5 operations. - The lightweight Mockito approach (mock endpoint + client, call
process()directly) is appropriate here -- no CamelContext startup overhead needed since the exception is thrown before any AWS client call. assertj-coreis correctly added without a version (managed by the parent POM).
No issues found. LGTM.
|
🌟 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).
|
Child of CAMEL-24261 (completing CAMEL-23462 across the AWS2 producers).
Problem
With
pojoRequest=true,AWSConfigProducer's five operations (putConfigRule,removeConfigRule,describeRuleCompliance,putConformancePack,removeConformancePack) only acted when the body was the matching request type;any other body fell through the
instanceofwith noelse, so no AWS call wasmade, no response was set, and the original body was returned with no error.
Fix
Each branch now throws
IllegalArgumentExceptionnaming the required requesttype, e.g.
"putConformancePack operation requires PutConformancePackRequest in POJO mode".Test
camel-aws-confighas no producer route/mock harness, so this is covered by a newMockito parameterized unit test that mocks the endpoint + client, sends a
wrong-typed body with
pojoRequest=true, and asserts eachIllegalArgumentException.Verified 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