Repository navigation
Description
Bug Description
The email gateway platform gets silently enabled by blank-but-present environment variables, then retries a connection to an empty hostname forever — and on a small VPS the memory growth from that loop eventually OOM-kills the entire host.
An abandoned email/Google Workspace setup left these lines in ~/.hermes/.env uncommented but with empty values:
EMAIL_ADDRESS=
EMAIL_PASSWORD=
EMAIL_IMAP_HOST=
EMAIL_SMTP_HOST=
EMAIL_ALLOWED_USERS=
The presence of these keys — even though every value is empty — appears to switch the email platform on. With an empty EMAIL_IMAP_HOST, the gateway then tries to open an IMAP connection to an empty hostname, which fails DNS resolution and logs this roughly every poll interval (~30 seconds):
ERROR gateway.platforms.email: [Email] IMAP connection failed: [Errno -2] Name or service not known
WARNING gateway.run: ✗ email failed to connect
Errno -2 is EAI_NONAME — there is no host to resolve, so this is a permanent failure, not a transient network blip, yet the gateway keeps retrying it indefinitely.
On a 4 GB host with no swap, memory consumption climbed over time until the OOM killer brought the machine down. sshd and the Tailscale daemon were starved along with everything else, so the box became completely unreachable: SSH would complete the key exchange and authenticate, then drop the connection before a session could start (the host couldn't fork the session process). Recovery required a hard power-cycle from the cloud console. After commenting out the five EMAIL_* lines, the gateway runs clean and memory holds flat at about 110 MB.
I want to be upfront that the unbounded memory growth is inferred from the failure pattern — this was the only recurring error in the logs, it fired every poll interval, and the swapless host died after enough hours — rather than confirmed with a heap profile. The behavior was consistent across two separate occurrences.
Steps to Reproduce
7:27 PMClaude responded: On a host running the hermes-gateway service (mine was Ubuntu 22.
On a host running the hermes-gateway service (mine was Ubuntu 22.04, ARM64, 4 GB RAM, no swap; Hermes Agent 0.16.0), open ~/.hermes/.env.
Add these lines as keys with empty values — present but blank, not commented out:
EMAIL_ADDRESS=
EMAIL_PASSWORD=
EMAIL_IMAP_HOST=
EMAIL_SMTP_HOST=
EMAIL_ALLOWED_USERS=
(In my case this was leftover residue from an abandoned email setup — the .env.example ships these commented, but a partial setup left them uncommented and then cleared.)
3. Start or restart the gateway: sudo systemctl restart hermes-gateway.
4. Watch the logs: journalctl -u hermes-gateway -f. Within a few seconds the email platform attempts to connect and begins logging, repeating roughly every poll interval (~30s):
ERROR gateway.platforms.email: [Email] IMAP connection failed: [Errno -2] Name or service not known
WARNING gateway.run: ✗ email failed to connect
Leave it running and watch process memory over time, e.g. systemctl status hermes-gateway or systemctl show hermes-gateway -p MemoryCurrent. On a small/swapless host, RSS grows until the OOM killer eventually takes down the machine.
Expected: with no EMAIL_IMAP_HOST (and/or empty EMAIL_ADDRESS), the email platform should be treated as not configured and skipped, or it should fail fast once and stay down — not retry a blank host indefinitely.
Workaround that fixes it: comment out the five EMAIL_* lines so the keys are absent rather than empty, then restart. The error stops and memory holds flat.
Expected Behavior
7:28 PMClaude responded: Hermes should treat an email platform with no usable connection settings as not configured, and simply not start it.Hermes should treat an email platform with no usable connection settings as not configured, and simply not start it.
Concretely, any one of these would have prevented the outage:
Empty means off. An EMAIL_ADDRESS= or EMAIL_IMAP_HOST= with an empty value should be treated the same as the key being absent — the email platform stays disabled. A present-but-blank env var shouldn't be enough to switch a platform on.
Validate before connecting. If the email platform is enabled, it should check that the required fields (host, address, credentials) are actually populated before attempting a connection. With a missing host it should log one clear line — something like email platform disabled: EMAIL_IMAP_HOST not set — and stay down, rather than dialing an empty hostname.
Don't retry a permanent failure forever. [Errno -2] Name or service not known on a blank host is not a transient network blip — it will never succeed. The gateway should stop retrying after a failure like this, or at minimum apply a capped exponential backoff, instead of looping at the poll interval indefinitely.
A failed/disabled optional platform should never be able to take down the host. Even setting the config questions aside, a misconfigured optional integration repeatedly failing to connect should not grow memory without bound. Its failure path shouldn't leak, and ideally a single non-critical platform couldn't exhaust host memory regardless.
The short version: an unconfigured or misconfigured optional integration should fail quietly and harmlessly — log it, skip it, move on — never retry into the void and never threaten the whole machine.
Actual Behavior
The email platform was started despite having no usable configuration (all EMAIL_* values were empty), immediately tried to open an IMAP connection to an empty hostname, failed DNS resolution, and then retried that same doomed connection on a loop. On a small, swapless host the memory growth from that loop eventually exhausted RAM and the OOM killer took down the entire machine, making it unreachable over SSH.
The recurring log output, repeating roughly every poll interval (~30 seconds):
ERROR gateway.platforms.email: [Email] IMAP connection failed: [Errno -2] Name or service not known
WARNING gateway.run: ✗ email failed to connect
[Errno -2] is EAI_NONAME — there is no host to resolve — so this is a permanent failure, but the gateway kept retrying it indefinitely rather than giving up or disabling the platform.
Over time (the host had been up ~13 days) memory consumption climbed until the kernel OOM-killer fired. Because the host had no swap, the failure was abrupt and total: sshd and the Tailscale daemon were starved along with everything else. The visible symptom from outside was that SSH would complete the full key exchange and authenticate successfully, then drop the connection before a shell could start — the host no longer had the memory to fork a session process:
debug1: Server accepts key: .../id_ed25519 ED25519 SHA256:...
debug3: sign_and_send_pubkey: signing using ssh-ed25519 ...
debug3: send packet: type 50
Connection closed by port 22
The machine was only recoverable by a hard power-cycle from the cloud provider's console (a graceful "shutdown" didn't work — the host was too starved to honor the ACPI request). After each reboot the gateway started leaking again, and on the freshest boot the box re-bricked within minutes, confirming the loop was active from startup.
After commenting out the five empty EMAIL_* lines in ~/.hermes/.env and restarting, the email platform no longer starts, the IMAP error is gone entirely, and memory holds flat at about 110 MB over a sustained run.
One note for accuracy: the unbounded memory growth is inferred from the failure pattern — this was the only recurring error in the logs, it fired every poll interval, and the swapless host died repeatably — rather than confirmed with a heap profile. I didn't capture per-process memory over the full leak window, but the behavior was consistent across multiple reproductions and stopped completely once the email platform was disabled.
Affected Component
Gateway (Telegram/Discord/Slack/WhatsApp)
Messaging Platform (if gateway-related)
N/A (CLI only)
Debug Report
Debug bundle withheld to avoid publishing credentials — my ~/.hermes/.env contains live API keys and the directory holds google_client_secret.json / google_token.json, and `hermes debug share` uploads config to a public paste. Happy to provide a redacted bundle or specific details privately on request.
Environment: Hermes Agent 0.16.0, hermes-gateway systemd service, Ubuntu 22.04 ARM64, Hetzner CAX11 (2 vCPU / 4 GB RAM, no swap), Python 3.11.
Relevant log lines (the only recurring error, ~every 30s until the host OOM'd):
ERROR gateway.platforms.email: [Email] IMAP connection failed: [Errno -2] Name or service not known
WARNING gateway.run: ✗ email failed to connect
Trigger: ~/.hermes/.env contained EMAIL_ADDRESS=, EMAIL_PASSWORD=, EMAIL_IMAP_HOST=, EMAIL_SMTP_HOST=, EMAIL_ALLOWED_USERS= — all present but empty (leftover from an aborted email setup). Commenting out all five lines stops the email platform from starting; the IMAP error disappears and memory holds flat (~110 MB).Operating System
Ubuntu 22.04
Python Version
3.11.15
Hermes Version
Hermes Agent v0.16.0 (2026.6.5) · upstream ebed881
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
Activity
liuhao1024 commentedon Jun 8, 2026
This is fixed by #40829 — validate email config before connect to prevent crash.
fix(email): mark missing-config as non-retryable + reject blank env v…
fix(email): mark missing-config as non-retryable + reject blank env v…
feat: live card tool progress chain + commentary accumulation (#21)
fix(email): mark missing-config as non-retryable + reject blank env v…
fix(email): mark missing-config as non-retryable + reject blank env v…
fix(email): mark missing-config as non-retryable + reject blank env v…
fix(email): mark missing-config as non-retryable + reject blank env v…
fix(email): mark missing-config as non-retryable + reject blank env v…
teknium1 commentedon Jul 14, 2026
Implemented on current
main.Automated hermes-sweeper review verified that the fix for this report was merged as
f79e0a7060d0303f4f248d2e03b101909748e781(fix(email): mark missing-config as non-retryable + reject blank env vars (#40715)). This also matches the prior discussion pointing to #40829.plugins/platforms/email/adapter.py:161strips and rejects blank/whitespace requiredEMAIL_*values, so abandoned empty.enventries do not satisfy platform requirements.plugins/platforms/email/adapter.py:551validates configuration beforeIMAP4_SSL; missing settings setemail_missing_configurationwithretryable=False.gateway/run.py:7120queues only retryable fatal errors;gateway/run.py:7948removes non-retryable failures from the reconnect queue.tests/gateway/test_email.py:1627verifies no IMAP call for a blank host and verifies the non-retryable fatal state;tests/gateway/test_email.py:1653covers blank and whitespace-only env values.fix(email): mark missing-config as non-retryable + reject blank env v…
fix(email): mark missing-config as non-retryable + reject blank env v…
fix(email): mark missing-config as non-retryable + reject blank env v…
fix(email): mark missing-config as non-retryable + reject blank env v…