Repository navigation
feat(platform): sync and triage every connected mailbox - #2916
Merged
Merged
Conversation
Mail sync only ever read the connector's default credential. An org
with two IMAP mailboxes — Recruitment and General Support — had one of
them silently unread until someone promoted it, and promoting it
stopped the other.
Walk every active credential instead, each from its own watermark, and
advance that watermark from the newest body the pass actually fetched.
Reading it from the listed envelopes would only work for IMAP: Gmail
lists `{id, threadId}` and Graph lists `receivedDateTime`, so neither
carries the `sentAt` the envelope path looked for, and both would have
sat at no watermark forever — refetching the same newest page every
run and losing anything that fell out of it. Bodies also mean the
watermark never steps past a message the fetch leg dropped.
A mailbox that fails is skipped for that pass and reported in the
result, not thrown: one expired password used to abort the run and
starve every mailbox behind it in the fan-out. A pass where all of
them fail still throws, so a broken connector stays loud.
Inbox triage gets the same reach through a new
`conversation.list_mailbox_messages`, which also ends the provider
dialect the three triage packs each carried: they now differ only by
the `connectorSlug` they pass, and their digests name the mailbox each
message came from.
Israeltheminer
force-pushed
the
feat/sync-every-connected-mailbox
branch
from
August 5, 2026 09:25
ab2a5b1 to
1e93b48
Compare
This was referenced Aug 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Mail sync only ever read the connector's default credential. An org with two IMAP mailboxes — say Recruitment and General Support — had one of them silently unread until someone promoted it, and promoting it stopped the other. Same for a second Gmail account.
conversation.sync_mailboxnow walks every active credential on the connector, each from its own watermark. Inbox triage gets the same reach through a newconversation.list_mailbox_messages.The watermark has to come from bodies, not envelopes
This is the part worth the closest read. The obvious source for "how far did this pass get" is the newest
sentAtin the listed envelopes. That only works for IMAP:list_messagesreturnsgmail{ id, threadId }— no timestamp at alloutlookreceivedDateTime(ISO string)imap-smtpsentAt(epoch ms)An envelope-derived watermark leaves Gmail and Outlook unset forever: every scheduled pass re-lists the newest
limitmessages, re-fetches all their bodies, and anything that arrived beyond that window between passes is never picked up. So the tip is read from the fetched, normalized bodies — the one shape all three providers converge on. That also means the watermark can never step past a message the fetch leg dropped.Gmail's
datefalls back tointernalDate, which is epoch ms as a string —new Date(...)returns Invalid Date on it, so the parse handles the numeric form too.One bad mailbox no longer starves the rest
A credential that fails (expired password, unreachable host) is caught, logged, reported in
inbound.reason, and the fan-out continues. Previously the throw aborted the pass, so every mailbox after the broken one in the iteration order never synced — permanently, since the default sorts first. A pass where every credential fails still throws, so a genuinely broken connector stays loud.Watermarks are persisted per credential inside the loop, so mailboxes that already succeeded keep their progress even when a later one fails.
Triage packs lose their provider dialect
The three
*/triage-inboxpacks each carried their own query dialect (q: in:inbox/top+orderby/limit+mailbox). That dialect now lives inconversation.list_mailbox_messages, so the three documents differ only by theconnectorSlugthey pass. The parity test is tightened to match: it substitutes that one value and compares everything else, so a driftedlimitexpression or a pack pointed at the wrong connector both fail. IMAP UIDs are unique only per mailbox, so ids are scoped by credential name and each digest entry names the mailbox it came from.Docs
platform/admin/connectors,platform/automations/builtin, anddevelop/connectorsin en / de / fr — the default-credential rule now has a named exception, and the per-mailbox position and skip-on-failure behaviour are described where an admin will look for them.Tests
Fan-out from independent watermarks, first-pass tail for a never-synced mailbox, Gmail's timestamp-free envelopes still advancing,
internalDatestring parsing, separate Inbox/Sent watermarks, failure isolation, all-failed throw, and the triage fan-out. Every new assertion was checked against a deliberately broken implementation before being kept. Green: 74,378 server tests, 194 docs, 1,165 i18n/UI.