fix(cron): harden ticker thread, null-safe deliver, and BSM env loader#33527
Open
zccyman wants to merge 1 commit into
Open
fix(cron): harden ticker thread, null-safe deliver, and BSM env loader#33527zccyman wants to merge 1 commit into
zccyman wants to merge 1 commit into
Conversation
Three cron bugs fixed in one PR (root cause cluster: cron lifecycle fragility): 1. NousResearch#32895 P1: Ticker thread dies silently on unexpected exceptions. The while loop body was only partially wrapped — errors from channel directory refresh, cache cleanup, or curator runs propagated up and killed the thread with no error log. Fix: wrap the ENTIRE loop body in a top-level try/except with ERROR-level logging. 2. NousResearch#32896 P2: `hermes cron list` crashes on null deliver field. job.get("deliver", ["local"]) returns None when the key exists but has null value. Fix: use `or` fallback instead of default arg. 3. NousResearch#33465 P2: cron/scheduler.py uses bare load_dotenv() instead of load_hermes_dotenv(). This skips BSM secret resolution, so any cron job needing BSM-managed credentials fails with HTTP 401. Fix: swap to load_hermes_dotenv(hermes_home=_get_hermes_home()) to preserve profile-aware path resolution. Tests: 381 passed (including updated profile context tests).
This was referenced May 28, 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.
Summary
Three cron bugs fixed in one PR (root cause cluster: cron lifecycle fragility).
Bug 1 — Ticker thread stops silently (#32895) P1
Root cause:
_start_cron_ticker()ingateway/run.pywrapscron_tick()in try/except, but the rest of the while loop body (channel directory refresh, cache cleanup, curator run) runs outside any exception handler. An unexpected error in any of these kills the thread with no error log.Fix: Wrap the entire while loop body in a top-level
try/except Exceptionwithlogger.error(..., exc_info=True). The thread now survives any single-iteration failure and retries on the next cycle.Bug 2 —
hermes cron listcrashes on null deliver (#32896) P2Root cause:
job.get("deliver", ["local"])returnsNonewhen the key exists but has anullvalue. Then", ".join(None)throwsTypeError.Fix:
job.get("deliver") or ["local"]— handles both missing key AND null value.Bug 3 — Cron uses bare
load_dotenv()instead ofload_hermes_dotenv()(#33465) P2Root cause:
cron/scheduler.pycallsfrom dotenv import load_dotenvdirectly, skipping BSM secret resolution,.envsanitization, and encoding fallback thatload_hermes_dotenv()provides. Cron jobs needing BSM-managed credentials fail with HTTP 401.Fix: Replace with
from hermes_cli.env_loader import load_hermes_dotenvand callload_hermes_dotenv(hermes_home=_get_hermes_home())to preserve profile-aware path resolution.Files Changed
gateway/run.pycron/scheduler.pyload_dotenv()→load_hermes_dotenv(hermes_home=...)hermes_cli/cron.pyjob.get("deliver", [...])→job.get("deliver") or [...]tests/cron/test_cron_profile.pyload_hermes_dotenvin profile testsTesting
tests/cron/,tests/hermes_cli/test_cron.py,tests/hermes_cli/test_env_loader.py)load_hermes_dotenvcallCloses #32895, Closes #32896, Closes #33465