CAMEL-24264: camel-aws2-translate - throw when pojoRequest=true and the body is the wrong type - #25158
Conversation
…he body is the wrong type Child of CAMEL-24261. Translate2Producer.translateText only acted when the body was a TranslateTextRequest 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. 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>
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
gnodet
left a comment
There was a problem hiding this comment.
Clean, minimal fix that follows the established CAMEL-23462 pattern for rejecting wrong-type bodies in POJO mode. The fix, test, and dependency addition are all correct.
Verified details:
- The fix correctly adds an
elseclause throwingIllegalArgumentExceptionwhenpojoRequest=truebut the body is not aTranslateTextRequest— structurally identical to the pattern established in CAMEL-23462 forBedrockProducer. - The test correctly uses
hasRootCauseInstanceOf(IllegalArgumentException.class)to unwrap through theCamelExecutionExceptionwrapper, and reuses the existingdirect:translatePojoTextroute. - The
assertj-coretest dependency is justified and correctly omits the version (managed by parent BOM). - No mixing of AssertJ and JUnit assertions within the same test method.
- Git history confirms the silent fall-through was original code with no prior intentional changes.
This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.
Claude Code on behalf of Guillaume Nodet
|
🧪 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,Translate2Producer.translateTextonly acted when thebody was a
TranslateTextRequest; any other body fell through theinstanceofwith no
else, so no AWS call was made, no response was set, and the originalbody was returned with no error.
Fix
Test
translateTextWithPojoRequestAndWrongBodyTypeThrowssends a wrong-typed body tothe existing
pojoRequest=trueroute and asserts the message. Verified to fail(silent no-op) before the fix. Class 4/4 green.
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