[ 
https://issues.apache.org/jira/browse/CAMEL-24344?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Work on CAMEL-24344 started by Andrea Cosentino.
------------------------------------------------
> camel-google-mail: raw option always returns a null body and non-multipart 
> messages produce no body
> ---------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-24344
>                 URL: https://issues.apache.org/jira/browse/CAMEL-24344
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-google-mail-stream
>            Reporter: Andrea Cosentino
>            Assignee: Andrea Cosentino
>            Priority: Major
>
> {{GoogleMailStreamConsumer}} always requests the FULL format:
> {code:java}
> // GoogleMailStreamConsumer.java:95
> Message mess = getClient().users().messages().get("me", 
> message.getId()).setFormat("FULL").execute();
> {code}
> but the {{raw}} option then reads a field the Gmail API only populates for 
> {{format=RAW}}:
> {code:java}
> // GoogleMailStreamConsumer.java:190-191
> if (getConfiguration().isRaw()) { message.setBody(mail.getRaw()); }
> {code}
> so {{raw=true}} always produces a null body. See 
> https://developers.google.com/workspace/gmail/api/reference/rest/v1/users.messages
>  - "Returned in messages.get and drafts.get responses when the format=RAW 
> parameter is supplied."
> The non-raw path only handles multipart messages:
> {code:java}
> // GoogleMailStreamConsumer.java:193-198
> List<MessagePart> parts = mail.getPayload().getParts();
> if (parts != null && parts.get(0).getBody().getData() != null) { ... }
> {code}
> A plain (non-multipart) mail has {{getParts() == null}} and its content in 
> {{getPayload().getBody().getData()}}, so the body is silently left unset. 
> {{mail.getPayload()}} and {{getPayload().getHeaders()}} (:200) are also 
> dereferenced without a null check.
> Minor: {{processRollback}} (:169-181) adds the UNREAD label back even when 
> {{markAsRead}} is false, and its catch block reports "Error occurred mark as 
> read mail" for a rollback failure.
> Found during a source audit of the {{components/camel-google}} module family 
> against main @ c3b01310be15.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to