CAMEL-24317: camel-aws2-eventbridge - throw when pojoRequest=true and the body is the wrong type - #25255
Conversation
… the body is the wrong type Child of CAMEL-24261. EventbridgeProducer.putRule only acted when the body was a PutRuleRequest 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 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>
|
🌟 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.
The production fix is correct — putRule was missing the else branch to throw when pojoRequest=true and the body is not a PutRuleRequest, matching the CAMEL-24261 series pattern. The test logic is sound and compiles/passes correctly (assertj-core is already available on main).
Minor observation (not blocking):
putRule is the only operation in EventbridgeProducer that was not migrated to use the executeOperation helper (all other operations — putTargets, removeTargets, deleteRule, enableRule, disableRule, listRules, describeRule, listTargetsByRule, listRuleNamesByTarget, putEvent — already use it). The error message format here ("putRule operation requires PutRuleRequest in POJO mode") differs from executeOperation's more debuggable format ("Expected body of type %s but was %s") which includes both the expected and actual type names. Consider either migrating putRule to use executeOperation or matching its error message format for consistency and debuggability.
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
Addresses gnodet's review: putRule threw a bespoke "putRule operation requires
PutRuleRequest in POJO mode" message while every other operation goes through
executeOperation, which throws String.format("Expected body of type %s but was
%s", ...). Match that format for consistency and debuggability, and update the
test assertion accordingly.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Andrea Cosentino <ancosen@gmail.com>
gnodet
left a comment
There was a problem hiding this comment.
Re-review after new commit: the second commit correctly addresses the previous review feedback by aligning the putRule error message format with executeOperation's pattern. The else-branch now uses the same String.format("Expected body of type %s but was %s", ...) with the ObjectHelper.isNotEmpty null-guard, and the test assertion was updated to match. CI passes on both JDK 17 and 25.
Claude Code on behalf of Guillaume Nodet
Child of CAMEL-24261 (completing CAMEL-23462 across the AWS2 producers).
Problem
With
pojoRequest=true,EventbridgeProducer.putRuleonly acted when the bodywas a
PutRuleRequest; any other body fell through theinstanceofwith noelse, so no AWS call was made, no response was set, and the original body wasreturned with no error. (The other Eventbridge operations already build their
request from headers and don't have a pojo branch.)
Fix
Test
camel-aws2-eventbridgehas no producer route/mock harness, so this is coveredby a new Mockito unit test (
EventbridgeProducerPojoRequestTest) that mocks theendpoint + client, sends a wrong-typed body with
pojoRequest=true, and assertsthe
IllegalArgumentException. 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