Skip to content

fix(gmail): exclude send-as aliases from gmail send --reply-all - #1318

Closed
saariuslystoned wants to merge 2 commits into
openclaw:mainfrom
saariuslystoned:fix/gmail-send-reply-all-aliases
Closed

saariuslystoned wants to merge 2 commits into
openclaw:mainfrom
saariuslystoned:fix/gmail-send-reply-all-aliases

Conversation

@saariuslystoned

@saariuslystoned saariuslystoned commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

What problem this solves

gmail reply-all and gmail drafts create --reply-all leave out every address that belongs to the user. They pass selfEmailsForReply(account, from.sendingEmail, sendAs), which covers the account, the sending address and every send-as alias. gmail send --reply-all calls buildReplyAllRecipients(replyInfo, from.sendingEmail) instead, so it excludes only the sending address. It also discards the send-as list that resolveComposeSender has already fetched.

Take a message from alice sent to me@example.com, alias@example.com (a send-as alias) and bob:

gog gmail send --reply-to-message-id <id> --reply-all --body ok
  To: alice@example.com, alias@example.com, bob@example.com    <- copies the user's own alias
gog gmail send --reply-to-message-id <id> --reply-all --from alias@example.com --body ok
  To: alice@example.com, me@example.com, bob@example.com       <- copies the user's primary address
gog gmail reply-all <id> --body ok
  To: alice@example.com, bob@example.com

Change

gmail send fetches the send-as list once (listSendAs plus resolveComposeFrom, which is what resolveComposeSender does) and passes selfEmailsForReply(account, from.sendingEmail, sendAs) to buildReplyAllRecipients. That function now takes any number of addresses to exclude, so its existing callers are unchanged. Explicit --to/--cc still override the derived lists, as before.

Leaving out every self address can leave a reply-all with Cc recipients and no To, for example when replying to a message sent from your alias to your primary address with Cc bob. gmail reply-all sends that reply to Cc only. gmail send --reply-all now does the same: when --reply-all is set and --to is not, it checks To, Cc and Bcc together, and lets the MIME build omit To. Every other gmail send still requires a To recipient.

Evidence

  • TestGmailSendReplyAllExcludesSendAsAliases runs the three commands above through the CLI entry point against an httptest Gmail server and decodes the raw MIME that messages.send receives.

    • gmail reply-all is the control and passes on main (e8428c3).
    • Both gmail send --reply-all cases fail on main and pass with this change.
    • TestGmailSendReplyAllKeepsCcOnlyRecipients replies to a message from alias@example.com to me@example.com, Cc bob@example.com. gmail reply-all (control) sends it Cc bob. gmail send --reply-all at this PR's first head rejected it with no recipients, and with this change it sends it Cc bob.
    • The existing send, reply, reply-all and compose tests pass.
  • Built gog binaries from main and from this branch were run against a local Gmail stand-in through GOG_GOOGLE_API_BASE_URL (not Google). It lists send-as probe@example.com (primary) and alias@example.com, and decodes each messages.send body:

    $ gog --account probe@example.com gmail send --reply-to-message-id cc1 --reply-all --body ok
      (cc1: From alias@example.com, To probe@example.com, Cc bob@example.com)
    main:   exit=0  To: alias@example.com  Cc: bob@example.com     <- replies to the user's own alias
    branch: exit=0  To: (none)             Cc: bob@example.com
    
  • Live Gmail run with a real Workspace mailbox, self-addressed only. The original went from the account to itself with Cc a plus-address of the same mailbox, so nothing left it. Headers are as Gmail stored them, read back with gmail get --format metadata:

    original: From: agent@…  To: agent@…  Cc: agent+cc@…
    $ gog gmail send --reply-to-message-id <original> --reply-all --body '…'
    main (e8428c3): exit=2  no recipients: specify --to or use --reply-all with a message that has recipients
    this branch:    exit=0  stored reply  From: agent@…  To: (none)  Cc: agent+cc@…
    

    The account has no send-as aliases, so the alias cases above are covered by the tests and the stand-in run only. The probe messages were moved to Trash afterwards.

  • Every make ci step passed on a62176e (go1.27.3). The Go test suite (go test -count=1 ./...) ran on a second macOS arm64 machine, and the fmt, lint, deadcode, docs, agent-skills and node checks ran locally.

This changes local recipient computation only. The live run above sent only to the account's own mailbox.

🤖 Generated with Claude Code

gmail reply-all and drafts --reply-all leave out the account and every
send-as alias through selfEmailsForReply, but gmail send --reply-all
excluded only the sending address and dropped the send-as list it had
already fetched. A reply-all to a message addressed to an alias copied
the alias, and with --from <alias> it copied the primary address. Reuse
the fetched send-as list and selfEmailsForReply.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@clawsweeper

clawsweeper Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. P2 Normal priority bug or improvement with limited blast radius. merge-risk: 🚨 message-delivery 🚨 Merging this PR could drop, duplicate, misroute, suppress, or wrongly target messages. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 8, 2026
@clawsweeper

clawsweeper Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Exclude the account and all send-as aliases from derived reply-all recipients while permitting Cc-only replies.

Example: An email from alice@example.com addresses me@example.com, alias@example.com and bob@example.com, where alias@example.com is the user's send-as alias.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused, useful fix with shipped-CLI comparative proof, meaningful regression coverage and no outstanding findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): Contributor terminal output exercises built gog binaries through the real CLI and HTTP client against a Gmail stand-in, demonstrating account/alias exclusion and Cc-only messages.send payloads; a live Workspace run additionally verifies Gmail stores the Cc-only reply.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Reply-all copies the user's other identities and can reject a reply whose remaining recipients are in Cc.
Reason: The change restores established self-exclusion behavior while keeping the lower-level send command's existing recipient override contract.

Merge readiness

✅ Ready for maintainer review

This PR fixes a current recipient-selection bug with a focused patch; both earlier findings are resolved, and no actionable code defects remain.

Priority: P2
Reviewed head: a62176e24eafb5fcdf9ce3bca74b729bf2fd1c87

Before merge

None.

Findings

None.

Agent review details

How this fits together

The Gmail send command combines message headers, account identities and explicit recipient flags, builds MIME, and submits it through Gmail messages.send.

flowchart LR
 CLI[Send command] --> Identity[Account and send-as identities]
 CLI --> Original[Original message headers]
 Identity --> Recipients[Shared recipient builder]
 Original --> Recipients
 Recipients --> Overrides[Explicit recipient overrides]
 Overrides --> MIME[MIME builder]
 MIME --> Gmail[Gmail messages send]
Loading

Technical review

Best possible solution:

Land the focused reuse of shared self-address filtering and existing Cc-only MIME support.

Do we have a high-confidence way to reproduce the issue?

Current-main source establishes both failures, and the contributor supplies comparative CLI output; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The patch uses the existing recipient owner and MIME capability, preserves sender validation and explicit replacement semantics, and avoids a parallel implementation.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against e8428c36dd31.

Provenance checked

  • Send reply-all self exclusion and recipient validation changes intended behavior with a stated reason (bf7d500: Derive original sender and To/Cc recipients, filter self, and retain explicit replacement semantics.)
  • Sender resolution keeps the original intent (0ea6763: Centralize compose send plumbing; current resolveComposeSender delegates exactly to listSendAs and resolveComposeFrom.)
  • Shared reply recipient builder keeps the original intent (ba350d6: Provide stable Gmail-like reply primitives, including account and alias exclusion, while preserving send's replacement semantics.)
  • MIME construction keeps the original intent (9153264: Extract the MIME builder; older commit inspection encountered unavailable objects, but current source and tests explicitly support AllowMissingTo.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Current main still has the bug: Main excludes only from.sendingEmail and rejects an empty To list even when Cc recipients remain. (internal/cmd/gmail_send.go:197, e8428c36dd31)
  • Focused correction: The introduced diff retains the fetched send-as list, uses the existing selfEmailsForReply helper, preserves explicit overrides, and passes the existing MIME allowance through the batch sender. (internal/cmd/gmail_send.go:201, a62176e24eaf)
  • Existing recipient contract: The documented reply-all contract excludes the account and its aliases; feat(gmail): add first-class reply commands #803 established the shared implementation while retaining send's replacement semantics. Its maintainer discussion also records the recipient-safety constraint, which this patch preserves. (docs/gmail-workflows.md:434, ba350d6824ce)
  • Supplied behavior proof: The full PR body supplies built-binary main/branch output against a local Gmail stand-in, showing alias exclusion and Cc-only MIME, plus stored-header output from a live Workspace Cc-only reply. The live mailbox had no send-as aliases, as the author explicitly discloses. Captured body identity: d492cfa0d78a024bfd6a8ba641ff76a33ed3d4be2e3e16a08ab95a935f4b5d98. (a62176e24eaf)
  • Feature history: The original reply-all implementation intended self exclusion and explicit replacement semantics; subsequent compose and reply refactors retained the single-address send call. Some older refactor blobs are unavailable locally, limiting deeper historical inspection without affecting the verified current source comparison. (internal/cmd/gmail_send.go:112, bf7d500849a0)
  • Repository policy applied: The complete root AGENTS.md was read; no nested governing files, maintainer notes directory or pr-simplify skill were present. The Unreleased entry now includes the PR reference and contributor thanks. (AGENTS.md, a62176e24eaf)

Likely related people:

  • Peter Steinberger: Raw commit ba350d6 adds internal/cmd/gmail_reply.go:23 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: ba350d6824ce; files: internal/cmd/gmail_reply.go)

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P2: A bounded Gmail reply-all bug unnecessarily copies self aliases and rejects valid Cc-only replies.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (2 earlier review cycles)
  • reviewed 2026-11-08T15:51:58.848Z sha 3c7fa70 :: needs real behavior proof before merge. :: [P2] Allow replies whose remaining recipients are only in Cc | [P3] Add the required PR reference to the changelog entry
  • reviewed 2026-11-08T20:11:24.326Z sha a62176e :: needs maintainer review before merge. :: none

Reviewed November 8, 2026, 9:19 PM ET / November 9, 2026, 02:19 UTC (Revision 3).

Leaving every self address out of gmail send --reply-all can leave a reply with Cc recipients and no To, which gmail reply-all already sends. Validate the combined recipient set for reply-all and let the MIME build omit To in that case.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@saariuslystoned

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. merge-risk: 🚨 message-delivery 🚨 Merging this PR could drop, duplicate, misroute, suppress, or wrongly target messages. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 8, 2026
@saariuslystoned

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 9, 2026
@steipete

Copy link
Copy Markdown
Collaborator

Thank you for the fix. I reproduced the claim and consolidated excluding send-as aliases consistently from reply-all recipients into #1336, with regression coverage and your coauthor credit retained. The full make ci gate, built-CLI checks for the new request-validation fixes, and exact-head GitHub CI passed. Closing this PR as superseded by the merged implementation in #1336.

@steipete steipete closed this Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants