Skip to content

fix(imap): pass uid:true option to fix UID vs sequence number mismatch#3

Open
benv666 wants to merge 1 commit intojgalea:mainfrom
benv666:fix/imap-uid-sequence-mismatch
Open

fix(imap): pass uid:true option to fix UID vs sequence number mismatch#3
benv666 wants to merge 1 commit intojgalea:mainfrom
benv666:fix/imap-uid-sequence-mismatch

Conversation

@benv666
Copy link
Copy Markdown

@benv666 benv666 commented Apr 20, 2026

Fixes #2

NOTE: This PR is claude-generated.

Problem

All IMAP operations that accept a messageId treat it as an IMAP sequence number, but the IDs exposed to callers (via search_emails, inbox_summary) are UIDs.
On any real mailbox where messages have accumulated, the two diverge causing read_email to throw Command failed, modify_email to silently no-op, and trash_emails / download_attachment to target the wrong message or error.

Fix

Pass { uid: true } as the options argument to each affected imapflow call:

  • fetchOne in fetchMessage
  • messageFlagsAdd / messageFlagsRemove in modifyLabels
  • messageMove in trashMessages
  • fetchOne in downloadAttachment

The change is purely mechanical — 6 lines, no logic changes.

Notes

  • uid: true in the query object (e.g. { source: true, uid: true }) tells imapflow to return the UID in the result. The { uid: true } options argument tells imapflow to treat the range as a UID. These are different parameters — both are correct in their respective positions after this fix.
  • searchMessages has a related issue mixing sequence numbers and UIDs internally, but works today by coincidence. Worth a follow-up but out of scope here.

fetchOne, messageFlagsAdd, messageFlagsRemove, and messageMove all
received the message UID as their range argument but were missing the
{ uid: true } options flag, causing imapflow to treat it as a sequence
number. On any real mailbox the two diverge, breaking read_email,
modify_email, trash_emails, and download_attachment entirely.

Fixes jgalea#2
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.

IMAP provider: UID vs sequence number mismatch breaks read_email, modify_email, trash, and download_attachment

1 participant