Skip to content

fix(cron): normalize script paths before validation (#26595)#39627

Open
rodboev wants to merge 2 commits into
NousResearch:mainfrom
rodboev:pr/cron-script-path-normalize
Open

fix(cron): normalize script paths before validation (#26595)#39627
rodboev wants to merge 2 commits into
NousResearch:mainfrom
rodboev:pr/cron-script-path-normalize

Conversation

@rodboev

@rodboev rodboev commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Cron script paths are documented as relative to ~/.hermes/scripts/, but the cron tool currently joins the raw user string directly to that directory. A user-provided scripts/check.py therefore resolves as ~/.hermes/scripts/scripts/check.py, while a missing file can be stored even though execution later fails with a script-not-found error.

This normalizes script paths at the cron tool boundary, accepts one leading scripts/ prefix as user-friendly input, validates containment, verifies that the script exists before storing the job, and persists the normalized relative path. The existing-file requirement is intentional: the tool now rejects invalid cron job definitions before they are saved instead of deferring that failure until the scheduled run.

Fixes #26595.

Changes

  • tools/cronjob_tools.py: normalize cron script paths and return the normalized storage value on create and update.
  • tests/tools/test_cronjob_tools.py: add regression coverage for scripts/ prefix normalization, Windows separator normalization, missing-file rejection, traversal and absolute-path rejection, and update clearing.

Validation

Scenario Before After
script="scripts/check.py" Stored as scripts/check.py, resolving under a duplicate scripts directory Stored as check.py
script="scripts\\check.py" Stored with the raw separator form Stored as check.py
Missing script file Job could be stored and fail later at runtime Tool rejects the create or update request
Empty script on update Cleared the script field Still clears the script field

Test plan

  • python -m pytest tests/tools/test_cronjob_tools.py -v --timeout=0: 72 passed
  • Opus cross-provider review: PASS after fixing the reviewer-requested script_value consistency issue and adding Windows separator coverage

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/cron Cron scheduler and job management labels Jun 5, 2026
@rodboev rodboev force-pushed the pr/cron-script-path-normalize branch from 4234bdf to 724dfad Compare June 11, 2026 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cron Cron scheduler and job management P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cronjob: script path resolution silently doubles scripts/ prefix and skips missing-file validation

2 participants