fix(cron): gracefully degrade when runtime profile is deleted

Instead of raising FileNotFoundError (which silently bricks the job),
log a warning and fall back to the scheduler default home. Validates
at create/update time still catches typos. Idea from PR #19958.
This commit is contained in:
alt-glitch 2026-05-18 17:30:36 +00:00 committed by daimon-nous[bot]
parent 1d74d7f73a
commit ef5fe8dfaf
2 changed files with 25 additions and 11 deletions

View file

@ -354,23 +354,28 @@ class TestRunJobProfileContext:
assert observed["hermes_home_during_init"] == str(root)
assert os.environ["HERMES_HOME"] == str(root)
def test_run_job_rejects_missing_runtime_profile(
def test_run_job_falls_back_on_missing_runtime_profile(
self, isolated_cron_profile_home, monkeypatch
):
import cron.scheduler as sched
root, _profile_home = isolated_cron_profile_home
monkeypatch.setattr(sched, "_hermes_home", None)
observed: dict = {}
self._install_agent_stubs(monkeypatch, observed)
with pytest.raises(FileNotFoundError):
sched.run_job(
{
"id": "missing-profile",
"name": "missing-profile-job",
"profile": "missing",
}
)
job = {
"id": "missing-profile",
"name": "missing-profile-job",
"profile": "missing",
"schedule_display": "manual",
}
# Should succeed with fallback, not raise
success, _output, response, error = sched.run_job(job)
assert success is True, f"run_job should fallback, not fail: error={error!r}"
# Verify it used the default home, not the missing profile
assert observed["hermes_home_during_init"] == str(root)
assert os.environ["HERMES_HOME"] == str(root)