Skip to content

fix(gmail): restore --exclude-labels SPAM,TRASH,DRAFT,SENT in buildGogWatchServeArgs - #56736

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

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

Conversation

@JuniperTheDev

Copy link
Copy Markdown
Contributor

Summary

Fixes #56635 — regression introduced in 2026.3.24 where buildGogWatchServeArgs() stopped passing --exclude-labels to gog gmail watch serve, causing sent mail and draft saves to trigger webhook notifications.

  • Add excludeLabels field to HooksGmailConfig (type) and HooksGmailSchema (Zod) with default ['SPAM','TRASH','DRAFT','SENT']
  • Add excludeLabels to GmailHookRuntimeConfig and GmailHookOverrides types
  • Resolve excludeLabels in resolveGmailHookRuntimeConfig() (falls back to default)
  • Pass --exclude-labels <labels> in buildGogWatchServeArgs() when list is non-empty

Users can now override the excluded labels via hooks.gmail.excludeLabels in config.

Test plan

  • TypeScript type-check passes (tsc --noEmit)
  • All 8 existing gmail unit tests pass
  • Manual: gateway logs should show gog gmail watch serve --exclude-labels SPAM,TRASH,DRAFT,SENT ...
  • Manual: sending mail or saving a draft should no longer trigger webhook notifications

🤖 Generated with Claude Code

…gWatchServeArgs (fixes openclaw#56635)

Add excludeLabels field to HooksGmailConfig, HooksGmailSchema, GmailHookRuntimeConfig,
and GmailHookOverrides. Default to ['SPAM','TRASH','DRAFT','SENT']. Pass as
--exclude-labels flag in buildGogWatchServeArgs() to prevent sent mail and
draft saves from triggering webhook notifications.

Co-Authored-By: JuniperTheDev <[email protected]>
@greptile-apps

greptile-apps Bot commented Mar 29, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR restores the --exclude-labels flag to buildGogWatchServeArgs(), fixing a regression introduced in 2026.3.24 that caused SPAM, TRASH, DRAFT, and SENT messages to trigger unwanted webhook notifications. The fix is clean and well-scoped: it adds a DEFAULT_GMAIL_EXCLUDE_LABELS constant, threads excludeLabels through GmailHookOverrides → GmailHookRuntimeConfig → resolveGmailHookRuntimeConfig(), surfaces the field in both HooksGmailConfig (type) and HooksGmailSchema (Zod), and gates the CLI flag on a non-empty list so users can opt out entirely by setting excludeLabels: [].

Key observations:

  • The resolution chain (overrides.excludeLabels ?? gmail?.excludeLabels ?? DEFAULT_GMAIL_EXCLUDE_LABELS) correctly applies the expected priority order and the nullish-coalescing semantics mean an explicit empty array [] will propagate through and disable the flag (desired behavior).
  • The Zod schema is .strict(), so including excludeLabels in the schema object is required to avoid parse errors when users configure the field — this is handled correctly.
  • Field ordering in types.hooks.ts (excludeLabels after the tailscale block) differs slightly from zod-schema.hooks.ts (excludeLabels before serve), but this is purely cosmetic and has no runtime impact.
  • No new unit tests are added for the excludeLabels resolution path or the updated buildGogWatchServeArgs output, though the PR description notes all 8 existing tests pass.

Confidence Score: 5/5

Safe to merge — the fix is minimal, targeted, and correctly restores the previously working behavior with no logic errors.

All three changed files contain straightforward, low-risk additions. The resolution chain, Zod schema inclusion, and CLI arg building are all correct. No P0 or P1 issues were found; only cosmetic/style observations remain.

No files require special attention.

Important Files Changed

Filename Overview
src/hooks/gmail.ts Adds DEFAULT_GMAIL_EXCLUDE_LABELS constant, excludeLabels to types, resolves it in resolveGmailHookRuntimeConfig, and passes --exclude-labels flag in buildGogWatchServeArgs — all correct.
src/config/types.hooks.ts Adds excludeLabels?: string[] to HooksGmailConfig with a JSDoc comment; correct and consistent with the runtime types.
src/config/zod-schema.hooks.ts Adds excludeLabels: z.array(z.string()).optional() to the strict HooksGmailSchema, required to avoid parse errors when users configure the field.

Reviews (1): Last reviewed commit: "fix(gmail): restore --exclude-labels SPA..." | 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 duplicate/superseded. The Gmail watcher regression is still real on current main, but #56720 is already the fuller open canonical fix for #56635; this PR omits the generated config surfaces, regression tests, docs, and changelog needed before merge.

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

Review details

Best possible solution:

Continue with #56720 or an equivalent canonical branch that restores the default SPAM,TRASH,DRAFT,SENT exclusion, preserves a documented hooks.gmail.excludeLabels override with empty-list opt-out, updates generated config metadata/docs/tests/changelog, and then closes #56635 plus duplicate PRs.

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

Yes. A high-confidence source-level reproduction is to resolve the default Gmail hook config and inspect buildGogWatchServeArgs() or buildGogWatchServeLogArgs() on current main; no runtime field or builder branch can emit --exclude-labels.

Is this the best way to solve the issue?

No. Threading an excluded-label list into the Gmail watcher is the right narrow behavior, but this PR is not the best merge target because #56720 already carries the same fix with generated config surfaces, docs, and regression coverage.

Security review:

Security review cleared: The diff only threads non-secret Gmail label IDs through config validation and subprocess argv; it does not touch CI, dependencies, lockfiles, permissions, publishing, or secret handling.

What I checked:

Likely related people:

  • steipete: GitHub commit history shows the original Gmail hooks wizard and related Gmail hook config/docs work, and later maintainer commits on adjacent watcher behavior. (role: introduced behavior and likely maintainer; confidence: high; commits: 523d9ec3c2e4, ca9b0dbc887d, 26ce65995f8f; files: src/hooks/gmail.ts, src/hooks/gmail.test.ts, src/hooks/gmail-ops.ts)
  • jverdi: Commit ca9b0db added the Gateway Gmail watcher startup path that spawns gog through the shared serve-args builder. (role: introduced watcher startup path; confidence: medium; commits: ca9b0dbc887d; files: src/hooks/gmail-watcher.ts, src/gateway/server.ts)
  • eleqtrizit: Recent merged work touched Gmail watcher startup arg logging and the exact Gmail log-args test surface affected by this fix. (role: recent adjacent maintainer; confidence: medium; commits: 851294126b30; files: src/hooks/gmail.ts, src/hooks/gmail.test.ts, src/hooks/gmail-watcher.ts)
  • antons: Prior Gmail serve-path work changed the same runtime config and serve argument area. (role: adjacent Gmail serve behavior contributor; confidence: medium; commits: 26ce65995f8f; files: src/hooks/gmail.ts, src/hooks/gmail.test.ts, src/hooks/gmail-ops.ts)

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

@openclaw-barnacle openclaw-barnacle Bot removed the stale Marked as stale due to inactivity label May 1, 2026
@clawsweeper clawsweeper Bot closed this May 1, 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