Repository navigation
fix: run the automation's stored setup_script_path instead of a hardcoded setup.sh - #759
Conversation
…oded setup.sh Fixes #343 Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: openhands <openhands@all-hands.dev>
|
📁 PR Artifacts Notice This PR adds or changes temporary PR-specific documents under |
|
Warning Your comment is too long (maximum is 65536 characters), so the coverage report was not added. See the job log for how to reduce it. |
all-hands-bot
left a comment
There was a problem hiding this comment.
This review was posted by an AI agent (OpenHands).
Scope: This belongs here — the automation service owns dispatch and sandbox lifecycle orchestration, and #343 targets this repo's execution.py. The "honour the field" direction was already stated in the issue, so no product decision is needed.
Assessment: No material correctness, security, or compatibility findings. The fix does exactly what #343 asks: both former hardcoded ([ ! -f setup.sh ] || bash setup.sh) sites (execute_in_context, run_automation) now run _setup_step(setup_script_path).
Verified against the workspace code:
- Backward compatibility:
None/"setup.sh"produces the byte-identical previous fragment, so presets, catalog bundles, and existing tarballs behave as before.run_automation's new kwarg defaults toNone, leaving existing callers unaffected. - Plugin-spec exclusion is correct and necessary:
/plugin-specstores the manifest's script path relative to the fetched plugin (router.py:576viasetup_script_for_manifest), while the runtime bundle only carries the rootsetup.shwrapper that runs$AUTOMATION_PLUGIN_ROOT/<script>(plugin_specs.py:1352-1360,AUTOMATION_PLUGIN_ROOTexported atdispatcher.py:1162). Passing the stored value would look in the wrong directory; passingNonereproduces the old fragment exactly, and the new test intest_dispatcher_private_plugins.pylocks this in with a stored non-default path. - Security:
validate_command_stringis enforced at create, PATCH, and git-sync import (loop.py:542);_setup_stepadditionally single-quotes both the path and the error message (verified by the quoting test with'and spaces). No new injection surface. - Git sync round-trips the field (serializer exports it, import revalidates), so synced automations keep the behavior.
- Windows:
windows_runner.pyis deliberately unchanged and the limitation is documented in the docstring and AGENTS.md step 7 — a pre-existing platform limitation, not a regression. - Behavior change (a stored non-default path missing from the tarball now fails fast before the entrypoint instead of being skipped silently) is the fix's stated intent and is disclosed in the Notes.
Tests: Ran tests/test_execution.py (68/68 passed, including the 12 new real-bash TestSetupStep/wiring tests) plus the non-Docker portions of the dispatcher/plugin tests locally. Docker-backed fixtures could not run in this workspace (no Docker daemon), but the head's GitHub Actions unit-tests, backend, and windows-tests checks are all green on d1f5fcc. The .pr/ evidence follows the repo's documented PR-artifact convention and check-pr-artifacts passed.
Design context (intent, before/after, compatibility risk, SHA-pinned links, live before/after evidence) meets the repository's review-guide bar.
✅ APPROVED
|
🚀 Released in 1.33.0. |
Why
Fixes #343.
setup_script_pathis validated, stored and echoed by the API, but no executor reads it. Both run paths execute a hardcoded([ ! -f setup.sh ] || bash setup.sh). A custom tarball that names its setup script anything else skips setup silently, and the run then fails in the entrypoint with nothing pointing at setup. This takes the "honour the field" option from the issue. It supersedes #390, which was closed as stale.Summary
execution._setup_step(setup_script_path)builds the setup fragment:None/"setup.sh": unchanged,([ ! -f setup.sh ] || bash setup.sh)(presets and existing tarballs behave as before).([ -f 'p' ] || { echo 'setup script not found in the tarball: p' >&2; exit 1; }) && bash 'p'. A path the automation names explicitly must exist, so a typo fails the run before the entrypoint with a clear message instead of being skipped silently. The path is shell-quoted even though the request validator already rejects metacharacters.execute_in_contextandrun_automationtakesetup_script_path. The dispatcher passesautomation.setup_script_path./plugin-specstores the manifest'sentrypoint.setup_script, which is relative to the fetched plugin, not the runtime bundle. The bundle already contains a rootsetup.shwrapper that runs$AUTOMATION_PLUGIN_ROOT/<setup_script>. Passing the stored value through would look for the script in the wrong directory, so the dispatcher passesNonefor them.windows_runner.py, which runssetup.py) is unchanged and documented as such.setup_script_pathAPI description and AGENTS.md describe the behaviour.How to Test
454 passed (plus the
run_automationwiring test added after). New tests:TestSetupStepruns the generated fragment in realbashin a temp dir. It covers: defaultsetup.shpresent or absent; a custom path runs instead of a rootsetup.sh; a missing custom path exits 1 before the entrypoint with the message; a failing setup stops the run; and quoting with'and spaces.execute_in_context,run_automationand the dispatcher (stored path passed through;Nonefor plugin specs).pre-commit(ruff, pyright, …) passes on the changed files.Live check: I ran the service from each checkout in local mode with a local agent-server (
openhands-agent-server1.62.0). I uploaded a tarball containingmain.pyandscripts/install.sh, created a custom automation with"setup_script_path": "scripts/install.sh", and dispatched it. Script and bundle:.pr/repro343.sh,.pr/343-bundle.Notes
setup_script_paththat is not in its tarball used to have it ignored. Now its runs fail withsetup script not found in the tarball: <path>. That is the silent-skip case the issue asks to remove. The presets and the Canvas UI (fix(automations): make the setup script optional for new custom automations OpenHands#18653) sendsetup.sh, which is unaffected.custom-automation.mdreference in OpenHands/extensions can now documentsetup_script_pathas working..pr/holds temporary review evidence only.This PR was created by an AI agent (OpenHands) on behalf of Graham Neubig.