fix(email): harden adapter against malformed IMAP responses (#2794 salvage) - #56956
Merged
Merged
Conversation
Salvage of #2794 by @CharmingGroot, ported to the relocated plugins/platforms/email/adapter.py: - Guard raw_email = msg_data[0][1] against IndexError/TypeError and non-bytes payloads. UIDs are added to _seen_uids before fetch, so an exception mid-batch permanently skipped every remaining message in the batch — now the bad message is logged and skipped instead. - Message-ID domain generation falls back to 'localhost' when EMAIL_ADDRESS lacks '@' (now via a shared _message_id_domain() helper covering all 3 send paths; the PR fixed 2 of 3).
teknium1
force-pushed
the
salvage/2794-email-imap-guards
branch
from
July 2, 2026 10:03
2880187 to
2825728
Compare
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.
Summary
One malformed IMAP fetch response can no longer silently lose messages — the email adapter marks UIDs seen before fetching, so an unguarded
msg_data[0][1]crash mid-batch permanently skipped every remaining message in that batch.Salvage of #2794 by @CharmingGroot, ported to the relocated
plugins/platforms/email/adapter.py(PR targeted the oldgateway/platforms/email.py) and widened: the Message-IDsplit('@')[1]fix now covers all 3 send paths via a shared helper (the PR fixed 2 of 3), plus a non-bytes payload guard.Changes
plugins/platforms/email/adapter.py: try/except aroundmsg_data[0][1](IndexError/TypeError → warn + skip),isinstance(bytes)payload check,_message_id_domain()helper withlocalhostfallback replacing 3 crash-pronesplit('@')[1]sitestests/gateway/test_email_robustness.py: 9 tests incl. the batch-continues-after-malformed-response contractscripts/release.py: AUTHOR_MAP entry for @CharmingGrootValidation
Infographic
Nous Research