Skip to content

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

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

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

Conversation

@lucaspretti

Copy link
Copy Markdown

Re-submission of #841, which was auto-closed by the stale bot before a maintainer could review it. Same diff, head branch unchanged; CLA already signed and Gemini review was green.

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

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
@changeset-bot

changeset-bot Bot commented Jun 14, 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

@googleworkspace-bot googleworkspace-bot added the area: core Core CLI parsing, commands, error handling, utilities label Jun 14, 2026
@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 the Gmail integration would silently drop 'Cc' recipients when headers arrived with non-canonical casing. By aligning the parsing logic with RFC 5322, the system now correctly handles various header casing formats, preventing data loss 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' from Microsoft Exchange/Outlook are correctly processed.
  • Consolidated Header Logic: Simplified the header matching logic by folding variations of 'Message-ID' into a single case-insensitive arm.
  • Regression Testing: Added a new test case to verify that non-canonical header casing is correctly parsed and that recipients are not silently dropped.
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.

@lucaspretti

Copy link
Copy Markdown
Author

Re-opening this here after #841 was auto-closed by the stale bot before a maintainer could look at it.

The change is small and self-contained: header-name matching in parse_message_headers is made case-insensitive per RFC 5322 §1.2.2, which fixes +reply-all silently dropping Cc recipients when the upstream MTA (commonly Exchange/Outlook) sends the header as CC. It ships a regression test and a changeset, the CLA is signed, and the previous checks were green.

Would a maintainer be able to take a look when there is a chance? Happy to rebase or adjust anything if needed. Thanks!

@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, in compliance with RFC 5322 §1.2.2. By converting header names to lowercase before matching, it prevents headers with non-canonical casing (such as 'CC' or 'FROM' from Microsoft Exchange/Outlook) from being silently dropped. A comprehensive unit test has been added to verify this behavior. There are no review comments, so I have no additional feedback to provide.

@github-actions

Copy link
Copy Markdown
Contributor

This PR has been inactive for 72 hours. Closing to keep the queue clean.

@github-actions github-actions Bot added the Stale label Jun 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR was closed because it has been stalled for 72 hours. Feel free to magically reopen it if you want to continue working on it!

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 Stale

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