CAMEL-24289: camel-aws2-textract - throw when pojoRequest=true and the body is the wrong type - #25210
Conversation
…e body is the wrong type Child of CAMEL-24261. Textract2Producer's nine operations (detectDocumentText, analyzeDocument, analyzeExpense, startDocumentTextDetection, startDocumentAnalysis, startExpenseAnalysis, getDocumentTextDetection, getDocumentAnalysis, getExpenseAnalysis) 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. A parameterized test covers all nine operations; 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.
Clean, focused PR that adds else branches throwing IllegalArgumentException for all 9 Textract operations when pojoRequest=true and the body is the wrong type. The pattern, error messages, and test structure are fully consistent with the sibling PR #25199 (camel-aws2-polly) in the CAMEL-24261 series.
Details
- All 9 operations in
Textract2Operationsare covered by both the productionelsebranches and the@CsvSourceparameterized test. - Error message format (
<operation> operation requires <RequestType> in POJO mode) is consistent with the polly PR and follows a clear, informative pattern. - Test correctly uses AssertJ (
assertThatThrownBy) withhasRootCauseInstanceOfandhasRootCauseMessage, and the new test method has proper package-private visibility. - The
assertj-coretest dependency addition inpom.xmlis appropriate and follows the same pattern as other AWS2 modules in this series.
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
|
🌟 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,Textract2Producer's nine operations only acted whenthe body was the matching request type; any other body fell through the
instanceofwith noelse, so no AWS call was made, no response was set, andthe original body was returned with no error.
Fix
Each branch now throws
IllegalArgumentExceptionnaming the required requesttype, e.g.
"analyzeExpense operation requires AnalyzeExpenseRequest in POJO mode".Tests
A
@ParameterizedTestcovers all nine operations, sending a wrong-typed body topojoRequest=trueroutes and asserting each message. Verified to fail (silentno-op) before the fix — with the
analyzeExpenseelse removed, exactly that casereports "Expecting code to raise a throwable". Class 12/12 green. Hermetic unit
tests, 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