Skip to content

feat: support --after/--before date filtering for IMAP sync#222

Open
arunim1 wants to merge 1 commit intowesm:mainfrom
arunim1:imap-date-filter
Open

feat: support --after/--before date filtering for IMAP sync#222
arunim1 wants to merge 1 commit intowesm:mainfrom
arunim1:imap-date-filter

Conversation

@arunim1
Copy link
Copy Markdown

@arunim1 arunim1 commented Mar 25, 2026

Summary

  • Wire --after/--before flags through to IMAP SEARCH SINCE/BEFORE criteria instead of ignoring them
  • Only warn about --query (which has no IMAP equivalent); date flags now work natively
  • No behavior change when flags are omitted (zero time = no filter)

This makes recurring IMAP syncs practical — scanning a rolling window via --after instead of enumerating the full mailbox each time.

Tested locally: --after with a recent date narrowed the server-side scan dramatically.

--

invalid date formats are silently ignored instead of returning an error

IIRC this is how the repo handles invalid date formats more generally (e.g. for Gmail too).

Solves this issue: #195

🤖 Generated with Claude Code

IMAP SEARCH natively supports SINCE/BEFORE criteria, so pass the
date flags through to the server instead of ignoring them. This
makes recurring syncs practical — scanning the last 2 weeks
instead of the full 77k+ message archive.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@roborev-ci
Copy link
Copy Markdown

roborev-ci bot commented Mar 25, 2026

roborev: Combined Review (0a64afa)

Verdict: The changes successfully add IMAP support for date filtering, but introduce a medium-severity issue where invalid date formats are silently ignored instead of returning an error.

Medium

  • Location: cmd/msgvault/cmd/syncfull.go:216-222
  • Problem: Invalid --after or --before values are silently ignored because time.Parse errors are dropped. A command like sync --after not-a-date will proceed without filtering and unexpectedly sync far more mail than requested instead of warning the user.
  • Fix:
    Validate the date flags once, check if err != nil, and return an explicit error (e.g., fmt.Errorf("invalid --after date format (use YYYY-MM-DD): %w", err)) to halt the sync on malformed input. Reuse the parsed values for both
    Gmail query construction and IMAP client setup.

Synthesized from 3 reviews (agents: codex, gemini | types: default, security)

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