fix(cron): catch RuntimeError from Path.expanduser() in lifecycle guard - #435
Open
hashbender wants to merge 1 commit into
Open
fix(cron): catch RuntimeError from Path.expanduser() in lifecycle guard#435hashbender wants to merge 1 commit into
hashbender wants to merge 1 commit into
Conversation
|
Review Complete Risk: 🟢 Low (12/100) — no findings · 27 LOC across 2 files Bug fix: handles RuntimeError from tilde path expansion in cron lifecycle guard, preventing crash during security path checks. Includes regression test for gateway restart loop. Files Reviewed (2 files) |
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.
Summary
cron/lifecycle_guard.py::_resolve_script_pathcallsPath(script_path).expanduser()to resolve a cron job'sscriptpath before scanning it for gateway-lifecycle commands (check_gateway_lifecycle, enforced incron.jobs.create_job— reachable via bothhermes cron createand the agent'scronjobmodel tool directly).Path.expanduser()raisesRuntimeError(notOSError) for a~user-shaped path with no matching system user:_read_script_for_scanning'sexcept OSError:doesn't catch this, so an LLM-authoredscriptvalue that happens to start with~someuser/...(a plausible thing for an agent to produce — the same trigger shape already fixed foragent/subdirectory_hints.pyin #c126a99fc, "LLMs use~for 'approximately'" or a guessed/malformed path) crashes cron job creation with an unhandledRuntimeErrorinstead of the intended gracefulGatewayLifecycleBlocked/pass-through behavior the module is designed around.Fix
Add
RuntimeErrorto the caught exceptions in_read_script_for_scanning, mirroring the exact fix already applied toagent/subdirectory_hints.py's threePath.expanduser()/Path.home()call sites in #c126a99fc.Test plan
test_tilde_unknown_user_script_does_not_crash— confirmed it fails with an uncaughtRuntimeErroron the pre-fix code (viagit stash) and passes after the fixpytest tests/hermes_cli/test_gateway_restart_loop.py -q— 66 passedruff checkon all changed files — cleancron/jobs.py,cron/scheduler.py) that does not includecron/lifecycle_guard.py— confirmed viagh pr view --json files. No overlap.Mirror-of: NousResearch#56517
NousResearch#56517