fix(cron): "Script not found" says scripts are per-profile and how to fix it
Cron scripts resolve only against the job's own profile scripts/ dir (by design, profiles never share files), so a job copied between profiles fails with a path that looks plausible and no hint about why. The runtime error now names the profile folder and the two fixes (copy the script, or `hermes cron edit`). Closes #94821. Builds on #105775 (creation-time existence check, credited).
This commit is contained in:
@@ -288,7 +288,13 @@ def _resolve_script_path(script_path: str) -> tuple[Optional[Path], Optional[str
|
||||
f"({scripts_dir_resolved}): {script_path!r}"
|
||||
)
|
||||
if not path.exists():
|
||||
return None, f"Script not found: {path}"
|
||||
# Scripts resolve against THIS profile's scripts/ dir by design (profiles never share files),
|
||||
# which is the usual reason a copied job cannot find a script that exists elsewhere (#94821).
|
||||
return None, (
|
||||
f"Script not found: {path}. Cron scripts are looked up only in this profile's folder "
|
||||
f"({scripts_dir_resolved}); if the job was copied from another profile, copy the script "
|
||||
f"there too, or edit the job with `hermes cron edit`."
|
||||
)
|
||||
if not path.is_file():
|
||||
return None, f"Script path is not a file: {path}"
|
||||
return path, None
|
||||
|
||||
@@ -107,6 +107,16 @@ class TestRunJobScript:
|
||||
assert success is True
|
||||
assert output == "relative works"
|
||||
|
||||
def test_missing_script_names_the_profile_folder(self, cron_env):
|
||||
"""Scripts resolve per profile (#4707); the runtime error must say so (#94821)."""
|
||||
from cron.scheduler_script import _run_job_script
|
||||
|
||||
success, output = _run_job_script("copied-from-other-profile.py")
|
||||
assert success is False
|
||||
assert "Script not found" in output
|
||||
assert str(cron_env / "scripts") in output and "profile" in output
|
||||
assert "hermes cron edit" in output
|
||||
|
||||
|
||||
def test_script_subprocess_env_sanitized(self, cron_env, monkeypatch):
|
||||
"""Cron scripts must not inherit Hermes provider env (SECURITY.md §2.3)."""
|
||||
|
||||
Reference in New Issue
Block a user