fix(cron): remove output dirs for completed one-shot jobs - #23560
Open
LeonSGP43 wants to merge 1 commit into
Open
fix(cron): remove output dirs for completed one-shot jobs#23560LeonSGP43 wants to merge 1 commit into
LeonSGP43 wants to merge 1 commit into
Conversation
Collaborator
teknium1
reviewed
Jul 13, 2026
teknium1
left a comment
Contributor
There was a problem hiding this comment.
Thanks for identifying the orphaned-output path. The premise remains valid on current main: cron/jobs.py:1426-1430 removes an exhausted job without cleanup, while save_job_output() creates its directory at cron/jobs.py:1914-1919.
Problems
- The direct
OUTPUT_DIR / job_idpath bypasses_job_output_dir()(cron/jobs.py:255-268). Currentremove_job()resolves the safe path before persisting deletion (cron/jobs.py:1363-1370); this branch needs the same fail-closed ordering. - Current main has two additional exhausted-one-shot deletion paths:
claim_dispatch()(cron/jobs.py:1501-1506) and_get_due_jobs_locked()(cron/jobs.py:1818-1830). They need equivalent cleanup for the bug class to be covered.
Suggested changes
- Resolve
_job_output_dir(job["id"])before removal/save, then clean it after persistence in all three paths. - Add seeded-output tests for repeat-limit, dispatch-limit, and stale-due removal.
Automated hermes-sweeper review.
| # Remove the job (limit reached) | ||
| jobs.pop(i) | ||
| save_jobs(jobs) | ||
| job_output_dir = OUTPUT_DIR / job_id |
Contributor
There was a problem hiding this comment.
Please use _job_output_dir(job["id"]) and resolve it before jobs.pop() / save_jobs(), as remove_job() now does. Directly composing OUTPUT_DIR / job_id bypasses the current legacy-ID path-escape guard in cron/jobs.py:255-268.
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.
What does this PR do?
Cleans up cron output directories when a completed one-shot job is auto-removed by the repeat-limit path, so stale output folders do not accumulate after the job record is deleted.
Related Issue
Fixes #22065
Type of Change
Changes Made
cron/jobs.pytests/cron/test_jobs.pyHow to Test
uv run --frozen pytest -q -o addopts='' tests/cron/test_jobs.py -k 'repeat_limit_removes_job or repeat_limit_removes_output_dir'uv run --frozen ruff check cron/jobs.py tests/cron/test_jobs.pyChecklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AScreenshots / Logs
uv run --frozen pytest -q -o addopts='' tests/cron/test_jobs.py -k 'repeat_limit_removes_job or repeat_limit_removes_output_dir'->2 passed