Skip to content

fix(gmail): include Cc, Bcc and Reply-To in gmail.get responses#389

Open
mickey-mikey wants to merge 5 commits into
gemini-cli-extensions:mainfrom
mickey-mikey:fix/gmail-get-cc-headers
Open

fix(gmail): include Cc, Bcc and Reply-To in gmail.get responses#389
mickey-mikey wants to merge 5 commits into
gemini-cli-extensions:mainfrom
mickey-mikey:fix/gmail-get-cc-headers

Conversation

@mickey-mikey
Copy link
Copy Markdown
Contributor

Fixes #388.

Problem

gmail.get extracted only Subject, From, To and Date for the metadata and full formats, silently discarding Cc, Bcc and Reply-To. Consumers could not tell who a message was copied to without falling back to format: "raw" and decoding the RFC 822 payload themselves — and the absence of a cc field reads as "no CC recipients", which is confidently wrong.

Changes

  • Extract Cc, Bcc and Reply-To in the metadata/full paths and include them in the response as cc, bcc, replyTo — omitted when the header is absent, so existing response shapes are unchanged for messages without them.
  • Make header-name matching case-insensitive (RFC 5322 §1.2.2 — header field names are case-insensitive).

Tests

  • New: headers present → fields returned; headers absent → fields omitted (no nulls); case-variant header names (from/TO/CC) still match.
  • Full suite: 622/622 passing.

🤖 Generated with Claude Code

@google-cla
Copy link
Copy Markdown

google-cla Bot commented Jun 6, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the GmailService to extract Cc, Bcc, and Reply-To headers from emails, ensuring case-insensitive header matching per RFC 5322, and adds comprehensive unit tests for these scenarios. The review feedback suggests a performance optimization in the getHeader helper function to convert the target header name to lowercase once outside the search loop, avoiding redundant operations.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread workspace-server/src/services/GmailService.ts Outdated
gmail.get silently dropped the Cc, Bcc and Reply-To headers in both
"metadata" and "full" formats, so callers could not see who an email
was copied to without falling back to format "raw" and decoding the
RFC 822 message themselves.

Also make header-name matching case-insensitive per RFC 5322.
@mickey-mikey mickey-mikey force-pushed the fix/gmail-get-cc-headers branch from 93aae7a to e507396 Compare June 6, 2026 05:46
@mickey-mikey
Copy link
Copy Markdown
Contributor Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for extracting 'Cc', 'Bcc', and 'Reply-To' headers from Gmail messages, handling header names case-insensitively, and includes corresponding unit tests. The feedback suggests optimizing the header lookup by building a case-insensitive lookup Map instead of performing repeated linear scans, and simplifying the conditional property spreading since JSON.stringify automatically omits undefined values.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread workspace-server/src/services/GmailService.ts Outdated
Comment thread workspace-server/src/services/GmailService.ts Outdated
…fined omission

Addresses review feedback: O(N+M) header lookups via a lowercased
Map instead of repeated linear scans, and plain property passing
instead of conditional spreads since JSON.stringify already omits
undefined values.
@mickey-mikey
Copy link
Copy Markdown
Contributor Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates GmailService to extract Cc, Bcc, and Reply-To headers from Gmail messages, ensuring case-insensitive header matching per RFC 5322. It also adds corresponding unit tests. Feedback suggests using h.value != null instead of h.value !== undefined to prevent null values from being serialized in the final JSON response.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread workspace-server/src/services/GmailService.ts Outdated
gmail_v1.Schema$MessagePartHeader.value is string | null | undefined;
filtering with != null keeps null-valued headers out of the map so
they are omitted from the JSON response rather than serialised as
null. Tightens the map type to Map<string, string>.
@mickey-mikey
Copy link
Copy Markdown
Contributor Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates GmailService to extract Cc, Bcc, and Reply-To headers, and implements case-insensitive header matching using a Map to comply with RFC 5322. It also adds comprehensive unit tests for these changes. The review feedback correctly notes that the new Map implementation unconditionally overwrites duplicate headers, shifting the behavior from "first match wins" to "last match wins". To maintain backward compatibility, it is recommended to only set the header value if the key is not already present in the map.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread workspace-server/src/services/GmailService.ts
headers.find() returned the first matching header; the lookup map was
overwriting on duplicates, silently switching to last-match-wins.
Skip set() when the key already exists, with a test pinning the
behaviour.
@mickey-mikey
Copy link
Copy Markdown
Contributor Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the GmailService to extract additional email headers (Cc, Bcc, and Reply-To) and processes header names case-insensitively per RFC 5322. It also adds comprehensive unit tests to verify the extraction logic, including handling of missing, null, duplicate, and case-insensitive headers. There are no review comments, and I have no feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gmail.get silently drops Cc, Bcc and Reply-To headers in metadata/full formats

1 participant