CAMEL-24238: camel-aws2-ses - send RawMessage body content instead of the SdkBytes descriptor#25015
CAMEL-24238: camel-aws2-ses - send RawMessage body content instead of the SdkBytes descriptor#25015oscerd wants to merge 1 commit into
Conversation
… the SdkBytes descriptor
When the exchange body is an SES RawMessage, Ses2Producer built the outgoing
Content from the body converted to String, which for a RawMessage falls back
to Object.toString() on the SDK type. SdkBytes.toString() renders a debug
descriptor ("SdkBytes(bytes=0x46726f6d...)"), so the recipient received that
descriptor instead of the MIME payload.
Read the payload from RawMessage.data().asUtf8String() when the body is a
RawMessage, and cover it with a test asserting the sent text equals the
original MIME content.
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, well-targeted bug fix. SdkBytes.toString() returns a debug descriptor (e.g., SdkBytes(bytes=0x46726F6D...)) rather than the actual content — so when a RawMessage body was used, the email text was garbled with the descriptor string instead of the MIME content.
The fix correctly uses raw.data().asUtf8String() which decodes the actual byte content as UTF-8 — appropriate for MIME email content.
Test added: rawMessageBodyIsSentAsItsContentNotTheSdkBytesDescriptor() constructs a RawMessage with MIME content, sends it through the route, and verifies the actual content is preserved. The test would have caught the original bug (the assertion would fail comparing "SdkBytes(bytes=0x...)" against the expected MIME string).
Checklist:
- Bug fix — correct API usage (
asUtf8String()vstoString()) - Test — new test covers the exact bug scenario
- AssertJ dependency added (project standard for assertions)
- Commit convention —
CAMEL-24238:prefix - No public API changes
- CI — pending
Reviewed with Claude Code on behalf of gnodet. This review was generated by an AI agent and may contain inaccuracies; please verify all suggestions before applying.
davsclaus
left a comment
There was a problem hiding this comment.
Clean, focused bug fix. SdkBytes.toString() returns a debug descriptor (SdkBytes(bytes=0x...)), not the actual payload — asUtf8String() is the correct API.
Verified:
- The bug was introduced in
fe3d038cd6a9(CAMEL-21593, Jan 2025) whenRawMessagesupport was added — thetoString()vsasUtf8String()mistake has been present since the feature was first added - Routing logic in
process()dispatchesjakarta.mail.Messagebodies tosendRawEmail()and everything else (includingRawMessage) tosendEmail()viacreateMessage()— the fix targets the correct code path - Test
rawMessageBodyIsSentAsItsContentNotTheSdkBytesDescriptor()directly tests the regression: builds aRawMessagefrom a MIME string, sends it, and asserts the captured body equals the original content - New test uses AssertJ and drops
publicper project conventions; existing JUnit assertions left untouched - Comment explains WHY
asUtf8String()is used — a genuine SDK gotcha worth documenting - No scope drift, commit convention correct
Claude Code on behalf of davsclaus. This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.
|
🌟 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.
Correct one-line fix for a genuine bug introduced in CAMEL-21593 where SdkBytes.toString() yields a debug descriptor instead of the payload. The fix to use asUtf8String() is consistent with how other AWS components in the codebase extract text from SdkBytes. Test is appropriate and validates the fix.
Minor suggestions (non-blocking):
- The
assertj-coredependency is added solely for a singleassertThatcall. UsingassertEquals(mime, sent)would be consistent with the rest of the test file and avoid the extra dependency. - New test method uses package-private access while existing methods use
public void— minor style inconsistency.
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
Problem
Ses2Producer.createMessage()builds the outgoingContentfromexchange.getIn().getBody(String.class). When the body is an SESRawMessage, there is no type converter for it, so the conversion falls backto
Object.toString()on the SDK type.SdkBytes.toString()renders a debug descriptor, not the payload:That descriptor is what ends up in the e-mail body — the actual MIME content
is never sent.
Fix
When the body is a
RawMessage, read the payload fromRawMessage.data().asUtf8String():Note this path is distinct from the
jakarta.mail.Messagebody, which alreadygoes through
sendRawEmailand is unaffected.Test
SesComponentTest.rawMessageBodyIsSentAsItsContentNotTheSdkBytesDescriptor()sends a
RawMessageand asserts the text captured by the mock SES clientequals the original MIME string. The test fails on
mainwith theSdkBytes(bytes=0x...)descriptor and passes with the fix.assertj-coreis added test-scoped so the new assertion follows the project'sAssertJ preference; the pre-existing JUnit assertions in the file are left
untouched.
Backport
The same code is present on
camel-4.18.xandcamel-4.14.x, so this istargeted at 4.22.0, 4.18.4 and 4.14.9.
Claude Code on behalf of oscerd