Skip to content

Comments

gmail: improve filter error logging and add limit check#1192

Merged
elie222 merged 2 commits intomainfrom
fix/gmail-filter-logging-v4
Jan 4, 2026
Merged

gmail: improve filter error logging and add limit check#1192
elie222 merged 2 commits intomainfrom
fix/gmail-filter-logging-v4

Conversation

@elie222
Copy link
Owner

@elie222 elie222 commented Jan 4, 2026

User description

Description

This PR improves the error logging for Gmail filter creation failures and adds a diagnostic check for the 1,000 filter limit.

Changes

  • Log detailed error info (message, status, reason) when filter creation fails.
  • If a 500 error occurs, check the current filter count and provide a descriptive error message if the limit (1,000) is reached.

Generated description

Below is a concise technical summary of the changes proposed in this PR:

graph LR
GmailProvider_createFilter_("GmailProvider.createFilter"):::modified
createFilter_("createFilter"):::modified
GmailProvider_createAutoArchiveFilter_("GmailProvider.createAutoArchiveFilter"):::modified
createAutoArchiveFilter_("createAutoArchiveFilter"):::modified
GMAIL_API_("GMAIL_API"):::modified
GET_FILTERS_LIST_("GET_FILTERS_LIST"):::added
LOGGER_("LOGGER"):::added
GmailProvider_createFilter_ -- "Now forwards provider logger to createFilter." --> createFilter_
GmailProvider_createAutoArchiveFilter_ -- "Now forwards provider logger to auto-archive function." --> createAutoArchiveFilter_
createAutoArchiveFilter_ -- "Adds logger when calling createFilter for auto-archive." --> createFilter_
createFilter_ -- "On error, checks filters and may throw SafeError." --> GMAIL_API_
createFilter_ -- "Newly calls getFiltersList to verify filter count." --> GET_FILTERS_LIST_
createFilter_ -- "Logs failure details, parameters, and limit-check results." --> LOGGER_
classDef added stroke:#15AA7A
classDef removed stroke:#CD5270
classDef modified stroke:#EDAC4C
linkStyle default stroke:#CBD5E1,font-size:13px
Loading

Enhances Gmail filter creation by improving error logging and adding a diagnostic check for the 1,000 filter limit. Updates the createFilter utility function, used by GmailProvider, to log detailed error information and proactively identify when the filter limit is reached, providing a user-friendly message.

TopicDetails
Improve Error Logging Log detailed error information, including message, status, and reason, when Gmail filter creation fails within the createFilter utility.
Modified files (2)
  • apps/web/utils/gmail/filter.ts
  • apps/web/utils/email/google.ts
Latest Contributors(1)
UserCommitDate
elie222fix-gmail-expand-filte...January 04, 2026
Add Filter Limit Check Implement a diagnostic check for the Gmail filter limit (1,000) when a filter creation fails with specific HTTP statuses, throwing a SafeError if the limit is reached.
Modified files (1)
  • apps/web/utils/gmail/filter.ts
Latest Contributors(1)
UserCommitDate
elie222fix-gmail-expand-filte...January 04, 2026
This pull request is reviewed by Baz. Review like a pro on (Baz).

@vercel
Copy link

vercel bot commented Jan 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
inbox-zero Ready Ready Preview Jan 4, 2026 4:08pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 4, 2026

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

Two utility files are modified to add logging support and enhanced error handling to Gmail filter operations. The GmailProvider forwards a logger instance to filter utility functions, while the filter utilities now accept a logger parameter and implement SafeError-based limit checking that fetches the current filter list when approaching Gmail's threshold.

Changes

Cohort / File(s) Summary
Logger Parameter Propagation
apps/web/utils/email/google.ts
GmailProvider.createFilter and GmailProvider.createAutoArchiveFilter now forward logger: this.logger to underlying utility functions.
Enhanced Error Handling & Limit Checking
apps/web/utils/gmail/filter.ts
Added logger: Logger parameter to createFilter and createAutoArchiveFilter. Implemented SafeError-based limit detection: when Gmail API returns 500, 403, or 400 status, fetches current filter list to check if near-limit threshold (990) and throws SafeError conditionally. Added error logging via logger when filter creation fails.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • baz-reviewer

Poem

🐰 A logger now hops through the filter terrain,
Catching each error with logging refrain,
Near Gmail's limit, we peek and we check,
SafeErrors prevent a mail-handling wreck! 📧✨

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6d0c8be and 60bbf13.

📒 Files selected for processing (2)
  • apps/web/utils/email/google.ts
  • apps/web/utils/gmail/filter.ts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@macroscopeapp
Copy link
Contributor

macroscopeapp bot commented Jan 4, 2026

Add logger to apps/web/utils/email/google.GmailProvider.createFilter and createAutoArchiveFilter, and implement Gmail filter limit check at 990 in apps/web/utils/gmail/filter.createFilter

Require and propagate a logger to Gmail filter utilities and add error handling that logs failures and throws a SafeError when existing filters count is >= 990 in filter.ts; update provider methods in google.ts to pass the logger.

📍Where to Start

Start with createFilter in filter.ts, then review calls from GmailProvider.createFilter and GmailProvider.createAutoArchiveFilter in google.ts.


Macroscope summarized 60bbf13.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

@elie222 elie222 merged commit f72181b into main Jan 4, 2026
15 of 17 checks passed
@elie222 elie222 deleted the fix/gmail-filter-logging-v4 branch January 4, 2026 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant