Keep member mail out of Spam, and let sync survive a vanished message - #2
Open
nam-jaehyun wants to merge 1 commit into
Open
nam-jaehyun wants to merge 1 commit into
nam-jaehyun wants to merge 1 commit into
Conversation
Mail redistributed by a Google Group loses SPF and DKIM alignment on the second hop, so legitimate mail to a member address was classified as spam -- and marking it "not spam" in Gmail did not stick, because the next message arrived through the same path and was judged the same way. Provisioning now creates a Gmail filter per member address matching list:<local>.<domain>, the list id the group stamps on every redistribution, with SPAM removed. Existing members are exempted once per process on the first sync tick, so an upgrade does not require re-approving anyone. Separately, messages.get returning 404 -- a message deleted or swept between the history record and the fetch -- failed the whole batch and left the sync cursor stuck on it, stopping delivery entirely. Skip those.
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.
Why
Legitimate mail to a member address was landing in Spam, and pressing Not spam did not make it stick.
A provisioned member address is a Google Group with the shared mailbox as its only member, so every message takes a second hop. That hop breaks SPF alignment and rewrites the envelope, so the spam classifier sees mail whose authentication does not line up with its From. Gmail's per-sender "not spam" decision keys on the sender, not on the path — the next message arrives the same way and is judged the same way.
Separately, sync had stopped entirely.
messages.getreturned 404 for a message that was gone between the history record and the fetch (deleted in Gmail, or swept from Spam), that rejection failed the whole batch, and the history cursor stayed parked on it. No new mail arrived at all;/healthzreportedlastError: "Requested entity was not found.".What changed
ensureNeverSpam()insrc/google/provisioning.tscreates one Gmail filter per member address matchinglist:<local>.<domain>— the list id the group stamps on every redistribution — withSPAMremoved. It is idempotent: existing filters are read back and matched on the query before creating anything.provisionMember()calls it aftercreateGroupAlias(), non-fatally. A member is still provisioned if the filter call fails.exemptMembersOnce()insrc/web/server.tsruns the same exemption over already-active members on the first sync tick, so upgrading does not mean re-approving anyone. It retries on the next tick if it throws.fetchAndStore()insrc/google/sync.tsskips a message whosemessages.getreturns 404 instead of failing the batch.Verification
Deployed and confirmed against the live tenant: six filters present (
list:support.boanlab.com,list:admin.boanlab.com,list:contact.boanlab.com, and the threekloud.zoneequivalents), and/healthzback to{"ok":true,"connected":true,"sync":{"ok":true,"staleSeconds":7,"consecutiveFailures":0,"lastError":null}}with mail arriving again.tsc --noEmitclean; 256/256 tests pass.Note
The filter suppresses Gmail's own classification on the way in. It does not fix authentication, so mail sent from a member address still depends on domain DKIM being configured — that requirement is already in
docs/deployment.md.