Skip to content

fix(gmail): match message headers case-insensitively (#642)#841

Open
lucaspretti wants to merge 2 commits into
googleworkspace:mainfrom
lucaspretti:fix/case-insensitive-message-headers
Open

fix(gmail): match message headers case-insensitively (#642)#841
lucaspretti wants to merge 2 commits into
googleworkspace:mainfrom
lucaspretti:fix/case-insensitive-message-headers

Conversation

@lucaspretti

@lucaspretti lucaspretti commented Jun 10, 2026

Copy link
Copy Markdown

Summary

gws gmail +reply-all silently drops Cc recipients when the original message's Cc header arrives with non-canonical casing (e.g. CC), which is common with Microsoft Exchange / Outlook. The original To recipients survive but the entire Cc list is lost, so a reply-all can go out missing people from the thread with no error.

Root cause

parse_message_headers (crates/google-workspace-cli/src/helpers/gmail/mod.rs) matched header names with an exact, case-sensitive match. Per RFC 5322 §1.2.2 header field names are case-insensitive, and the Gmail API preserves the original casing from the sending MTA, so CC (and any other non-canonical casing) fell through to _ => {} and was silently dropped.

Fix

Match on the lowercased header name so all casings are recognized. This also folds the previous "Message-ID" | "Message-Id" special-case into a single "message-id" arm.

Test

Adds test_parse_original_message_case_insensitive_headers, which feeds Exchange-style casing (FROM, TO, CC, cc, message-id) and asserts every recipient and the message id are parsed (i.e. Cc is not dropped).

Fixes #642

@changeset-bot

changeset-bot Bot commented Jun 10, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 68e85e5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@googleworkspace/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses an issue where Gmail message headers with non-canonical casing were being silently ignored during parsing. By normalizing header names to lowercase before matching, the system now correctly handles various casing formats, ensuring that critical recipient information is preserved during reply-all operations.

Highlights

  • Case-Insensitive Header Parsing: Updated the Gmail message header parsing logic to use case-insensitive matching, ensuring headers like 'CC' are correctly identified regardless of their casing.
  • Regression Testing: Added a new test case to verify that non-canonical header casing from external MTAs (like Microsoft Exchange) is correctly parsed, preventing silent recipient drops.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Generative AI Prohibited Use Policy, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@google-cla

google-cla Bot commented Jun 10, 2026

Copy link
Copy Markdown

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.

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

Copy link
Copy Markdown
Contributor

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 Gmail message header parsing logic to be case-insensitive, adhering to RFC 5322 §1.2.2. By converting header names to ASCII lowercase before matching, it ensures that headers with non-canonical casing (such as 'CC' or 'FROM') are not silently dropped. A new unit test has been added to verify this behavior. I have no feedback to provide.

@googleworkspace-bot googleworkspace-bot added the area: core Core CLI parsing, commands, error handling, utilities label Jun 10, 2026
Microsoft Exchange / Outlook emit non-canonical header casing (e.g. "CC"),
and the Gmail API preserves the original casing. parse_message_headers
matched header names case-sensitively, so +reply-all silently dropped Cc
recipients (and any header not in canonical casing) per RFC 5322 1.2.2.

Match on the lowercased header name, and add a regression test covering
uppercase FROM/TO/CC and lowercase message-id.

Fixes googleworkspace#642
@lucaspretti lucaspretti force-pushed the fix/case-insensitive-message-headers branch from 7215141 to 716ee9c Compare June 10, 2026 03:33
@googleworkspace-bot

Copy link
Copy Markdown
Collaborator

/gemini review

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

Copy link
Copy Markdown
Contributor

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 Gmail message header parsing in crates/google-workspace-cli/src/helpers/gmail/mod.rs to be case-insensitive, adhering to RFC 5322 §1.2.2. By converting header names to ASCII lowercase before matching, it ensures that headers with non-canonical casing (such as 'CC' or 'FROM') are not silently dropped. A new unit test has been added to verify this behavior. I have no feedback to provide.

@lucaspretti

Copy link
Copy Markdown
Author

@googlebot I signed it!

2 similar comments
@lucaspretti

Copy link
Copy Markdown
Author

@googlebot I signed it!

@lucaspretti

Copy link
Copy Markdown
Author

@googlebot I signed it!

@googleworkspace-bot

Copy link
Copy Markdown
Collaborator

/gemini review

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

Copy link
Copy Markdown
Contributor

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 fixes Gmail message header parsing to be case-insensitive (per RFC 5322 §1.2.2) by converting header names to lowercase before matching. This prevents headers with non-canonical casing (such as 'CC' from Microsoft Exchange or Outlook) from being silently dropped. A unit test has been added to verify this behavior. There are no review comments, so I have no feedback to provide.

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

Labels

area: core Core CLI parsing, commands, error handling, utilities

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(gmail): parse_message_headers uses case-sensitive match, drops CC/headers with non-canonical casing

2 participants