fix(cron): one-shot jobs report 'failed' after successful completion - #63570
Closed
natehale wants to merge 1 commit into
Closed
fix(cron): one-shot jobs report 'failed' after successful completion#63570natehale wants to merge 1 commit into
natehale wants to merge 1 commit into
Conversation
One-shot jobs (repeat=1) are auto-removed by mark_job_run after success. _execute_job_now then reads the job back to check last_status, but get_job returns None (job removed), so success is incorrectly set to False and CLI prints 'Ran now: failed'. Fix: when get_job returns None and run_one_job returned True, treat the absence as one-shot completion (the job ran and was cleaned up). Also use the _r fallback dict for last_error access to avoid a potential AttributeError when refreshed is None.
natehale
force-pushed
the
fix/cron-oneshot-status-report
branch
from
July 13, 2026 04:13
740f140 to
54bc587
Compare
Author
|
Closing as duplicate of #57689 — same root cause (mark_job_run removes one-shot jobs before _execute_job_now reads back last_status), and their approach is more complete: capturing structured success/error/delivery_error at the source via instead of inferring from absence. Our alternative fix (inferring success when get_job returns None and processed=True) is simpler but less robust — it can't surface the actual error or delivery_error. #57689 is the better vehicle for this fix. |
This was referenced Aug 2, 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.
Symptom
hermes cron run <job-id>on a one-shot job (repeat=1) printsRan now: failedeven though:~/.hermes/cron/output/Job '...' completed successfullyRoot cause
mark_job_run()incron/jobs.pyremoves one-shot jobs fromjobs.jsonwhen the repeat limit is reached (line ~1544). It setslast_status="ok"on the in-memory dict first, but that dict is then popped from the list and discarded — the job no longer exists on disk._execute_job_now()intools/cronjob_tools.pythen reads the job back viaget_job(job_id)to checklast_status. For one-shot jobs this returnsNone, sook = Falseandexecution_successis incorrectly set toFalse.Fix
In
_execute_job_now, afterrun_one_jobreturnsTrue, treat a missing job as one-shot completion rather than failure:Also uses the
_rfallback dict consistently forlast_erroraccess (defensive against aNonerefreshed in the error path).Scope
tools/cronjob_tools.py, 6 lines net)mark_job_run)Tests
tests/tools/test_oneshot_status_fix.pycovering:success=Truesuccess=Falsesuccess=True(unchanged)success=False(unchanged)claimed=False(unchanged)test_cronjob_run_immediatetests pass (5/5)Edge cases
processedget_job