fix: reject stale one-shot cron jobs - #59412
Conversation
Duplicate of #59410 — twin PR (both open, created ~3 min apart, both fix #59395). Same mechanism: reject one-shot jobs at |
|
Merged via #59438 (#59438). Your fix was cherry-picked with authorship preserved (commit 848089a on main) \u2014 chosen for its broader test coverage (the tool-boundary E2E test + load_jobs()==[] persistence assertion). I folded in a follow-up: (1) the grace-window seconds in the error message (from the competing #59410 by @isheng-eqi), and (2) the same guard on update_job's schedule-change path \u2014 a review found update_job had the identical unguarded compute_next_run->next_run_at pattern, so a user could re-create the ghost job by UPDATING a schedule to a past one-shot. Both are covered by new regression tests. Thanks for the fix and the thorough tests! Closing as merged. |
Summary
Problem
One-shot cron jobs created with a stale timestamp were accepted even though
compute_next_run()returnedNone. The job was saved with no next run time, so it appeared valid but never executed.Validation
/Users/arhaandesai/.hermes/hermes-agent/venv/bin/pytest -q tests/cron/test_jobs.py::TestJobCRUD::test_rejects_stale_past_one_shot_at_creation tests/cron/test_jobs.py::TestJobCRUD::test_recent_past_one_shot_within_grace_still_creates tests/cron/test_cron_script.py::test_cronjob_tool_rejects_stale_past_one_shot/Users/arhaandesai/.hermes/hermes-agent/venv/bin/pytest -q tests/cron/test_jobs.py tests/cron/test_cron_script.py/Users/arhaandesai/.hermes/hermes-agent/venv/bin/python -m py_compile cron/jobs.py tests/cron/test_jobs.py tests/cron/test_cron_script.py/Users/arhaandesai/.hermes/hermes-agent/venv/bin/python -m ruff check cron/jobs.py tests/cron/test_jobs.py tests/cron/test_cron_script.pyFixes #59395