CAMEL-24329: camel-aws2-s3 - throw when pojoRequest=true and the body is the wrong type - #25311
Conversation
… is the wrong type Child of CAMEL-24261. AWS2S3Producer's 22 pojo-capable operations (object and bucket operations, tagging, ACLs, versioning, policies) 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) over all 22 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.
🤖 AI-assisted review — Claude Code on behalf of @gnodet
Review: CAMEL-24329 — camel-aws2-s3 pojoRequest type validation
Clean, mechanical change following the established pattern from the CAMEL-24261 sweep (same as #25305 for camel-aws-config). Adds else branches to all 22 instanceof checks in the S3 producer's pojo-request code paths, throwing a clear IllegalArgumentException instead of silently doing nothing when the body is the wrong type.
Observations:
- All 22 pojo-capable operations covered
- The 5 operations without pojo paths (
listBuckets,headBucket,headObject,createDownloadLink,createUploadLink) correctly excluded - Error messages are consistent and name the expected type
- Null body handled by
getMandatoryBody()throwingInvalidPayloadExceptionbefore reaching the guard - Test is well-structured: Mockito parameterized test covering all 22 operations, package-private class/methods, AssertJ assertions
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: 10 tested, 29 compile-only — current: 10 all testedMaveniverse Scalpel detected 39 affected modules (current approach: 10).
|
Child of CAMEL-24261 (completing CAMEL-23462 across the AWS2 producers — this is the last producer in the sweep).
Problem
With
pojoRequest=true,AWS2S3Producer's 22 pojo-capable operations (object &bucket ops, tagging, ACLs, versioning, policies) only acted when the body was the
matching request type; any other body fell through the
instanceofwith noelse, so no AWS call was made, no response was set, and the original body wasreturned with no error.
Fix
Each branch now throws
IllegalArgumentExceptionnaming the required requesttype, e.g.
"createBucket operation requires CreateBucketRequest in POJO mode".Test
camel-aws2-s3has no producer route/mock harness, so this is covered by a newMockito parameterized unit test over all 22 operations. It mocks the endpoint +
client and sends a wrong-typed body with
pojoRequest=true. Because several s3operations resolve the bucket/key before the pojo-type check, the test supplies
bucketName/keyNameso the wrong-typed body reaches the guard being exercised.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