fix(gmail): surface missing Message-ID on --reply-to-message-id (#512)#528
Open
solomonneas wants to merge 1 commit intosteipete:mainfrom
Open
fix(gmail): surface missing Message-ID on --reply-to-message-id (#512)#528solomonneas wants to merge 1 commit intosteipete:mainfrom
solomonneas wants to merge 1 commit intosteipete:mainfrom
Conversation
When --reply-to-message-id resolved to a message whose metadata fetch returned no Message-ID header, replyInfoFromMessage produced empty InReplyTo/References and buildRFC822 silently skipped writing both threading headers. The send proceeded with only threadId set, so the Gmail UI threaded the reply but recipients on non-Gmail clients saw a brand-new message. fetchReplyInfo now returns a clear error in that case for the explicit message-id path. Default metadataHeaders for gog gmail get --format metadata now include Message-ID, In-Reply-To, and References so users can verify threading headers without supplying --headers explicitly. Fixes steipete#512.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #512.
Problem
When
gog gmail send --reply-to-message-id <id>(and thegmail drafts createequivalent) resolves to a message whose metadata fetch returns no
Message-IDheader,
replyInfoFromMessagesilently produces emptyInReplyTo/References,and
buildRFC822skips writing both threading headers because of itsTrimSpace == ""guards. The send proceeds with onlythreadIdset, the CLIreports success, the Gmail UI threads the reply, but recipients on non-Gmail
clients receive what looks like a brand-new message with no thread ancestry.
The reporter's repro inspects via
gog gmail get <id> --format metadata --json,but the default
--format metadataallowlist only containedFrom,To,Cc,Bcc,Subject,Date(plusList-Unsubscribe), so threading headers werefiltered out of the response regardless of whether they were actually set on
the wire. That made the bug genuinely silent end-to-end.
Fix
internal/cmd/gmail_send.go:fetchReplyInfonow returns a clear errorwhen the explicit
--reply-to-message-idpath resolves to a messagewithout a
Message-IDheader. Scoped to the explicit message-id path sodrafts update's implicit thread-id continuity (which can legitimatelyinclude drafts in the lookback) is unaffected.
internal/cmd/gmail_get.go: defaultmetadataHeadersfor--format metadatanow also includeMessage-ID,In-Reply-To, andReferences.Explicit
--headersbehavior is unchanged. JSON consumers reading.message.payload.headerswill see up to three additional headers whenpresent on the message.
Tests
TestFetchReplyInfo_NoMessageIDFails— explicit reply target with noMessage-IDreturns an error mentioningMessage-ID.TestFetchReplyInfo_ParentWithoutReferences— parent has onlyMessage-ID,child
Referencesequals parent MID,In-Reply-Toequals parent MID.TestFetchReplyInfo_ParentWithReferences— parent has bothMessage-IDandReferences, childReferencesequals parent References + parent MID,In-Reply-Toequals parent MID.TestExecute_GmailGet_Metadata_DefaultHeadersIncludeThreading— asserts thethree new headers ride along in the default metadata request.
Verification
make fmtclean,make lintreports0 issues.,make testgreen.go test -race -count=1 -run "Gmail|Reply" ./internal/cmd/clean.follow-up (same silent-failure class on
--thread-id) intentionally leftout of scope for a surgical fix.
Note re #516
PR #516 also targets this issue but takes a different approach (using the
existing draft's own message ID as the reply target in
drafts update).Happy to defer if maintainers prefer that path; this PR addresses the
underlying silent-failure mode and the diagnostic gap.