Skip to content

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

Merged
wesm merged 4 commits intowesm:mainfrom
arunim1:imap-date-filter
Apr 3, 2026
Merged

feat: support --after/--before date filtering for IMAP sync#222
wesm merged 4 commits intowesm:mainfrom
arunim1:imap-date-filter

Conversation

@arunim1
Copy link
Copy Markdown
Contributor

@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

@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)

arunim1 and others added 4 commits April 2, 2026 20:29
Invalid date strings were silently ignored, causing the sync to
fall back to fetching the entire mailbox. Now returns a clear
error with the expected YYYY-MM-DD format.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Move date flag validation to the top of syncFullCmd.RunE so malformed
dates are rejected before opening the database or iterating sources.
Previously, in a mixed Gmail+IMAP setup, Gmail sources could sync
successfully before the IMAP client builder rejected the bad date.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The test now writes client secrets and a fake token so the Gmail
source passes discovery checks. Without the early validation, Gmail
would be selected for syncing before the IMAP source rejects the
malformed date — making this a proper regression test.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@wesm wesm force-pushed the imap-date-filter branch from 0a64afa to 0494659 Compare April 3, 2026 13:55
@roborev-ci
Copy link
Copy Markdown

roborev-ci bot commented Apr 3, 2026

roborev: Combined Review (0494659)

Verdict: No medium-or-higher findings; the change looks clean based on all review outputs.

All three reviews found no issues, and there were no medium, high, or critical findings to report.


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

@wesm wesm merged commit 56e6e1a into wesm:main Apr 3, 2026
4 checks passed
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.

2 participants