Skip to content

fix: restore --exclude-labels SPAM,TRASH,DRAFT,SENT in Gmail watcher - #56726

Closed
JuniperTheDev wants to merge 1 commit into
openclaw:mainfrom
JuniperTheDev:fix/56635-gmail-exclude-labels-regression
Closed

JuniperTheDev wants to merge 1 commit into
openclaw:mainfrom
JuniperTheDev:fix/56635-gmail-exclude-labels-regression

Conversation

@JuniperTheDev

Copy link
Copy Markdown
Contributor

Summary

Fixes #56635.

The --exclude-labels SPAM,TRASH,DRAFT,SENT flag was passed to gog gmail watch serve in 2026.2.24 but was accidentally dropped in 2026.3.24. Without it only SPAM and TRASH are excluded by the gog CLI defaults, causing sent mail and draft saves to trigger webhook notifications and the agent to process the user's own outbound email.

Changes

  • src/hooks/gmail.ts: Restore the --exclude-labels SPAM,TRASH,DRAFT,SENT argument in buildGogWatchServeArgs().

🤖 Generated with Claude Code

…ixes openclaw#56635)

The --exclude-labels flag was present in 2026.2.24 but was accidentally dropped
in 2026.3.24. Without it, sent mail and draft saves trigger webhook notifications,
causing the agent to process the user's own outbound email.
@greptile-apps

greptile-apps Bot commented Mar 29, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR restores the --exclude-labels SPAM,TRASH,DRAFT,SENT argument to buildGogWatchServeArgs() in src/hooks/gmail.ts, which was accidentally dropped in a prior commit. Without this flag the gog CLI only excludes SPAM and TRASH by default, causing DRAFT saves and SENT messages to generate webhook notifications and be processed by the agent.

  • Fix: One-line restore of args.push(\"--exclude-labels\", \"SPAM,TRASH,DRAFT,SENT\") — correct and unconditional, matching pre-regression behavior.
  • No test coverage: buildGogWatchServeArgs has no unit test asserting the --exclude-labels argument is always present; adding one would prevent a silent regression like this in the future.

Confidence Score: 5/5

Safe to merge — the one-line restore is correct and matches the documented pre-regression behavior.

The change is a straightforward, targeted restore of a single argument that was accidentally dropped. Logic is correct, unconditional, and consistent with the original intent. No P0 or P1 issues found; the only observation is a missing unit test for this function path, which is P2.

No files require special attention, though adding a unit test for buildGogWatchServeArgs asserting --exclude-labels is always present would guard against future regressions.

Important Files Changed

Filename Overview
src/hooks/gmail.ts Restores the unconditional --exclude-labels SPAM,TRASH,DRAFT,SENT argument; change is correct and targeted.

Reviews (1): Last reviewed commit: "fix: restore --exclude-labels SPAM,TRASH..." | Re-trigger Greptile

@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@clawsweeper

clawsweeper Bot commented Apr 30, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

Close as superseded. Current main still has the Gmail watcher regression, but #56720 is the better canonical open PR for the same bug because it covers the same runtime argument path plus tests/docs/config-surface work, while this one-line PR is not merge-ready on its own.

So I’m closing this here and keeping the remaining discussion on the canonical linked item.

Review details

Best possible solution:

Use #56720, or a maintainer-approved narrow equivalent, as the canonical fix that restores DRAFT/SENT exclusion with updated Gmail args/log coverage and changelog/docs as appropriate.

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

Yes. A high-confidence source-level reproduction exists on current main by resolving Gmail hook defaults and inspecting buildGogWatchServeArgs(): OpenClaw does not pass --exclude-labels, while gogcli defaults only exclude SPAM,TRASH.

Is this the best way to solve the issue?

No as submitted. Restoring the runtime argument is the right narrow surface, but this branch leaves the focused test/changelog updates missing and is superseded by the more complete #56720 path.

Security review:

Security review cleared: The diff only adds a fixed non-secret CLI argument to an existing local gog spawn path and does not change dependencies, workflows, permissions, secrets handling, or downloaded code.

What I checked:

  • Current main omits the flag: buildGogWatchServeArgs() builds the gog gmail watch serve arguments through --hook-token, optional --include-body, and optional --max-bytes, with no --exclude-labels pair on current main. (src/hooks/gmail.ts:225, 0fbf4636f52c)
  • Normal watcher startup uses the same builder: Gateway Gmail watcher startup calls buildGogWatchServeArgs(cfg) before spawning gog, so the missing argument affects the configured watcher path. (src/hooks/gmail-watcher.ts:62, 0fbf4636f52c)
  • Manual Gmail run uses the same builder: The manual webhooks gmail run serve path also calls buildGogWatchServeArgs(cfg) before spawning gog. (src/hooks/gmail-ops.ts:358, 0fbf4636f52c)
  • PR diff is only the runtime arg: The PR head adds one line, args.push("--exclude-labels", "SPAM,TRASH,DRAFT,SENT"), in buildGogWatchServeArgs(). (src/hooks/gmail.ts:245, 01a8a731f1d1)
  • Focused test expectation would need updating: buildGogWatchServeLogArgs() delegates to the serve-args builder and the exact log-args expectation still omits --exclude-labels and SPAM,TRASH,DRAFT,SENT. (src/hooks/gmail.test.ts:90, 0fbf4636f52c)
  • Dependency contract supports the regression report: The upstream gogcli README and GmailWatchServeCmd source document watch serve --exclude-labels and its default of SPAM,TRASH, so DRAFT and SENT must be passed explicitly if OpenClaw wants them excluded.

Likely related people:

  • steipete: Commit 523d9ec added the Gmail hooks wizard and central Gmail hook files; later hooks/Gmail refactors by the same maintainer touched the same runtime and CLI surfaces. (role: introduced behavior and frequent maintainer; confidence: high; commits: 523d9ec3c2e4, 3a6ee5ee0017, 1fe9f648b1f6; files: src/hooks/gmail.ts, src/hooks/gmail-ops.ts, src/hooks/gmail.test.ts)
  • eleqtrizit: Commit 8512941 touched the Gmail watcher startup/logging path and the exact Gmail log-args test surface affected by adding this flag. (role: recent adjacent maintainer; confidence: medium; commits: 851294126b30; files: src/hooks/gmail.ts, src/hooks/gmail.test.ts, src/hooks/gmail-watcher.ts)
  • jverdi: Commit ca9b0db added src/hooks/gmail-watcher.ts, the gateway auto-start path that consumes buildGogWatchServeArgs(). (role: introduced watcher service; confidence: medium; commits: ca9b0dbc887d; files: src/hooks/gmail-watcher.ts)

Codex review notes: model gpt-5.5, reasoning high; reviewed against 0fbf4636f52c.

@openclaw-barnacle openclaw-barnacle Bot removed the stale Marked as stale due to inactivity label May 1, 2026
@clawsweeper clawsweeper Bot closed this May 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Gmail watcher regression: --exclude-labels dropped in buildGogWatchServeArgs

1 participant