Repository navigation
Open
Labels
P3Low — cosmetic, nice to haveLow — cosmetic, nice to havecomp/pluginsPlugin system and bundled pluginsPlugin system and bundled pluginsplatform/emailEmail (IMAP/SMTP) adapterEmail (IMAP/SMTP) adaptersweeper:risk-message-deliverySweeper risk: may drop, duplicate, misroute, or suppress messagesSweeper risk: may drop, duplicate, misroute, or suppress messagestype/bugSomething isn't workingSomething isn't working
Description
Bug Description
2026-04-30 21:29:36,163 ERROR gateway.platforms.email: [Email] IMAP fetch error: 'int' object has no attribute 'decode'
2026-04-30 21:24:42,963 INFO gateway.platforms.email: [Email] Adapter initialized for <email>@icloud.com
2026-04-30 21:24:42,964 INFO gateway.run: Connecting to email...
2026-04-30 21:24:44,094 INFO gateway.platforms.email: [Email] IMAP connection test passed. 3 existing messages skipped.
2026-04-30 21:24:45,351 INFO gateway.platforms.email: [Email] SMTP connection test passed.
... later ...
2026-04-30 20:42:39,102 ERROR gateway.platforms.email: [Email] IMAP fetch error: 'int' object has no attribute 'decode'
2026-04-30 20:46:02,329 ERROR gateway.platforms.email: [Email] IMAP fetch error: _ssl.c:1012: The handshake operation timed out
2026-04-30 20:47:22,904 ERROR gateway.platforms.email: [Email] IMAP fetch error: 'int' object has no attribute 'decode'
Steps to Reproduce
- Setup an IMAP and SMTP server. In this case it's for an iCloud email address.
- Restart the gateway
- Wait for it to fail
Expected Behavior
Email Messaging works as outlined in the documentation: https://hermes-agent.nousresearch.com/docs/user-guide/messaging/email
Actual Behavior
Email messaging does not work due to the error.
Affected Component
Gateway (Telegram/Discord/Slack/WhatsApp)
Messaging Platform (if gateway-related)
N/A (CLI only)
Debug Report
Impacted lines included above as these pastes included private information.Operating System
Ubuntu 22.04.5 LTS
Python Version
Python 3.14.4
Hermes Version
0.11.0
Additional Logs / Traceback (optional)
Root Cause Analysis (optional)
No response
Proposed Fix (optional)
No response
Are you willing to submit a PR for this?
- I'd like to fix this myself and submit a PR
Metadata
Metadata
Assignees
Labels
P3Low — cosmetic, nice to haveLow — cosmetic, nice to havecomp/pluginsPlugin system and bundled pluginsPlugin system and bundled pluginsplatform/emailEmail (IMAP/SMTP) adapterEmail (IMAP/SMTP) adaptersweeper:risk-message-deliverySweeper risk: may drop, duplicate, misroute, or suppress messagesSweeper risk: may drop, duplicate, misroute, or suppress messagestype/bugSomething isn't workingSomething isn't working
Activity
alt-glitch commentedon Apr 30, 2026
Likely duplicate of #12498 — same root cause: IMAP FETCH response contains non-bytes payloads (int/None) from iCloud, needs type guard before
.decode().alt-glitch commentedon Apr 30, 2026
Likely duplicate of #12498
mwhuss commentedon Apr 30, 2026
I believe you're right. The fix recommended in #12498 touches the same code Gemini just patched locally to try to resolve the issue.
fix(email): guard header decode against non-string IMAP chunks
fix(email): robustly parse IMAP fetch tuples before decoding RFC822 p…
mknightz commentedon May 10, 2026
Confirming this is iCloud-specific and tracing the actual mechanism in case it
helps maintainers pick between the existing PRs.
Reproduction
Hit the same
'int' object has no attribute 'decode'error fetching fromimap.mail.me.comwith iCloud+ Custom Domain. Persistent 100% loss on everyUNSEEN message; never observed against Gmail's IMAP for the same code path.
Mechanism
Three things compound to make this a permanent loss rather than a retryable
error:
iCloud responds to
(RFC822)with a single bare-bytes element like[b'<UID> (UID <uid>)']— no body data items at all.msg_data[0]isbytesnot the expected(envelope, body)tuple, somsg_data[0][1]evaluates to an
int(the ord of that byte).email.message_from_bytes(int)raises the
'int' object has no attribute 'decode'we see.The
exceptblock at the bottom of_fetch_new_messagesswallows theerror with
logger.error(...)and moves on.Crucially, the UID was already added to
_seen_uidsbefore the fetch(in-memory dedupe), AND the iCloud server set the
\Seenflag as a sideeffect of the
(RFC822)request itself. So subsequent UNSEEN searcheswon't find it AND the in-memory dedupe will skip it after restart — the
message is gone for good.
Gmail returns the standard
(envelope, body)tuple shape for(RFC822),which is why this is iCloud-specific.
Local fix
We run a fix that's equivalent to combining #14939 / #21987 (BODY.PEEK[] swap)
with #12498 / #18146 (defensive non-bytes guard) — the protocol switch addresses
factors 1 and 3, and the type guard catches any remaining shape variation as
defense in depth. Verified end-to-end against iCloud across multiple UIDs over
a one-week soak. Diff for reference:
main...mknightz:hermes-agent:fix/icloud-rfc822-empty-body
Not opening a PR — the existing queue covers it. Happy to comment on the
BODY.PEEK[] PRs with the iCloud-specific reproduction if that would help.