Claus Ibsen created CAMEL-27974:
-----------------------------------

             Summary: camel-google-mail: unknown labels disable the label 
filter, rollback marks read mails as unread, body charset ignored
                 Key: CAMEL-27974
                 URL: https://issues.apache.org/jira/browse/CAMEL-27974
             Project: Camel
          Issue Type: Bug
          Components: camel-google-mail
            Reporter: Claus Ibsen
             Fix For: 4.25.0


Found while improving the option descriptions of camel-google-mail for 
CAMEL-23832 (pull request https://github.com/apache/camel/pull/31202).
These are separate problems of the component; the descriptions change only 
documents the current behavior.

h4. 1. Unknown names in labels turn the label filter off
{{GoogleMailStreamEndpoint.createConsumer}} drops the names in labels that 
match no label of the mailbox without a message. When none match (a typo, for 
example), labelsIds is empty and no label filter is set, so the consumer takes 
every mail that matches the query, and marks it as read when markAsRead is on. 
The method also calls labels.get once per label of the mailbox, although 
labels.list already returns the names.
Proposed change: fail with an IllegalArgumentException that names the unknown 
labels, and use the names from labels.list.

h4. 2. Rollback marks a read mail as unread
{{GoogleMailStreamConsumer.processRollback}} adds the UNREAD label when 
markAsRead=true and the exchange fails, also when the mail was already read 
before it was consumed. With a query that matches read mails (no is:unread), a 
failed exchange turns a read mail into an unread one.
Proposed change: add UNREAD back only when the mail had it when consumed 
(CamelGoogleMailStreamLabelIds), or drop the rollback, as the mail is only 
marked as read on success.

h4. 3. The body is always decoded as UTF-8
{{GoogleMailStreamConsumer.extractBody}} decodes the part data as UTF-8 and 
ignores the charset of the Content-Type of the part, so a mail in ISO-8859-1 
gets a broken body.
Proposed change: use the charset parameter of the part, with UTF-8 as fallback.

h4. 4. Smaller issues
GoogleMailComponent declares its own configuration field, which hides 
AbstractApiComponent.configuration; getConfiguration() sets the hidden field 
but returns super.getConfiguration(), which stays null when no component option 
is set, so getClient() (used by the google-mail:update-message-labels 
transformer) fails with a NullPointerException instead of the "(clientId and 
clientSecret) or serviceAccountKey are required" message. 
GoogleMailStreamComponent.getClient only checks clientSecret != null, 
google-mail checks clientId and clientSecret for blank. maxResults 0 or 
negative is passed to Gmail unchanged.


_Claude Code on behalf of davsclaus_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to