fix(gmail): match message header names case-insensitively (#642)#847
fix(gmail): match message header names case-insensitively (#642)#847shigechika wants to merge 1 commit into
Conversation
parse_message_headers used exact-case string matching, so headers whose field names use non-canonical casing -- e.g. "CC" (common from Exchange/Outlook) or a lowercase "from" from some MTAs -- fell through and were silently dropped. This dropped CC recipients from +reply-all. Per RFC 5322 1.2.2 header field names are case-insensitive, and the sibling get_part_header already uses eq_ignore_ascii_case. Normalize the name to lowercase before matching, and add a regression test covering mixed-case FROM/to/CC/Reply-TO/subject/MESSAGE-ID/References. Fixes googleworkspace#642. Claude-Session: https://claude.ai/code/session_01EuRYoXhx7ozQWx19mAFLUS
🦋 Changeset detectedLatest commit: 78e0ae1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
Summary of ChangesHello, 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 were being silently ignored if their casing did not match the hardcoded strings in the parser. By normalizing header names to lowercase, the system now correctly handles various casing formats often produced by different MTAs and email clients like Outlook, ensuring that critical fields like CC are preserved during operations such as reply-all. Highlights
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
Code Review
This pull request fixes an issue where Gmail message headers were matched case-sensitively, causing headers with non-canonical casing (like "CC" or lowercase "from") to be silently dropped. The matching logic in parse_message_headers has been updated to normalize header names to lowercase before matching, and a corresponding unit test has been added to verify case-insensitive parsing. There are no review comments, so I have no feedback to provide.
|
Hey @shigechika, thanks for picking this up. I submitted the same fix in #846 (a re-submission of #841), but the stale bot closed both before a maintainer could take a look. Since the diff here is essentially identical, two small things from my version might be worth folding in:
No ownership concerns on my end, just flagging so whichever PR lands keeps the test coverage. Glad to see this getting fixed either way. |
|
Thanks @lucaspretti — sorry the stale bot got both of yours. Good news: both points you raised are already covered here:
Genuinely happy for whichever PR lands — the important thing is that #642 gets fixed. Thanks for flagging the test coverage either way. |
Summary
Fixes #642.
parse_message_headersmatched header field names with exact case:Gmail preserves the sender's original header casing, so a message whose
Ccheader arrives as
"CC"(very common from Exchange/Outlook) — or"from"lowercase from some MTAs — falls through the match and is silently dropped.
In practice this drops all CC recipients from
gws gmail +reply-all.Per RFC 5322 §1.2.2 header field names are case-insensitive. The sibling
get_part_headeralready useseq_ignore_ascii_case, so this just bringsparse_message_headersin line.Fix
Normalize the name to lowercase before matching:
(The previous
"Message-ID" | "Message-Id"arm collapses to a single"message-id".)Test
Adds
test_parse_message_headers_case_insensitive, covering mixed-caseFROM/to/CC/Reply-TO/subject/MESSAGE-ID/References.cargo buildclean;cargo test helpers::gmailgreen (235 passed).🤖 Generated with Claude Code