fix: honour the stored setup_script_path when executing automations - #390
Open
santhiprakash wants to merge 1 commit into
Open
fix: honour the stored setup_script_path when executing automations#390santhiprakash wants to merge 1 commit into
santhiprakash wants to merge 1 commit into
Conversation
santhiprakash
force-pushed
the
fix/setup-script-path
branch
from
August 27, 2026 03:40
79f8b17 to
0c24e92
Compare
- Problem: setup_script_path is validated, stored and echoed back by the API, but both executor paths run a hardcoded root setup.sh, so a tarball naming any other setup script silently skips its setup step and fails later in the entrypoint (issue OpenHands#343). - Fix: thread automation.setup_script_path from the dispatcher into execute_in_context (and add the same parameter to run_automation for the blocking path), interpolating the value with the existing _shell_quote helper and keeping the setup.sh default when unset. - Verification: uv run pytest tests/ -q --ignore=tests/integration (1460 passed); uv run pre-commit run --files <changed> (ruff, pycodestyle, pyright all passed). Co-Authored-By: Paperclip <noreply@paperclip.ing>
santhiprakash
force-pushed
the
fix/setup-script-path
branch
from
August 27, 2026 14:42
0c24e92 to
21efd5b
Compare
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.
Problem
setup_script_pathis accepted, validated, persisted and echoed back by the API, but no executor ever reads it. Both execution paths build... && cd {work_dir} && ([ ! -f setup.sh ] || bash setup.sh) && {entrypoint}with a hardcoded rootsetup.sh(execution.py:416,execution.py:581), so a tarball that names its setup script anything else silently skips its setup step and then fails in the entrypoint (typicallyModuleNotFoundError) with nothing in the logs pointing at the skipped setup. The presets are unaffected only because they hardcodesetup_script_path="setup.sh".Fixes #343 (option "Honour the field" from the issue).
Triage / Root cause
grep -rn setup_script_path openhands/onmainreturns only the request models (schemas.py), the router pass-through (router.py:137), the ORM model (models.py:84), the git-sync serializer and the preset constructions — the twocmdbuilders inexecution.pynever see the stored value, becauseexecute_in_contextdoes not receive it (the dispatcher has theAutomationrow in scope at its call site but only passesentrypoint).Fix
execute_in_contexttakes a newsetup_script_path: str | None = Noneparameter and interpolates it into the setup fragment with the existing_shell_quotehelper, keeping thesetup.shdefault when unset:([ ! -f '{path}' ] || bash '{path}'). The value is already validated at the request layer (relative, no..segments, no shell metacharacters), and single-quoting keeps a'in a stored path literal.run_automation(blocking path, used by the e2e scripts) gains the same parameter and interpolation.setup_script_path=automation.setup_script_pathat its single production call site.setup.shnow describe the configured setup script.Verification
uv run pytest tests/ -q --ignore=tests/integration→ 1460 passed (includes 4 new tests intests/test_execution.py::TestSetupScriptPath: custom path reaches the dispatch command, defaultsetup.shwhen unset, a single quote in the path stays escaped, and the blocking path honours the stored path).main@3efb91d(020_add_automation_disabled_reasonlanded after opening): full suite → 1473 passed, 0 failed; the dispatcher hunk composes cleanly with the new unhealthy-automation logic.main@f1b3244(release 1.9.0, includes SDK 1.44.0 bump chore: bump SDK to 1.44.0 #393; no hunk overlap with dispatcher/execution): targeted suitetests/test_execution.py+tests/test_dispatcher.py→ 85 passed, 0 failed on SDK 1.44.0; pre-commit (ruff format/lint, pycodestyle, pyright) all pass.uv run pre-commit run --files openhands/automation/execution.py openhands/automation/dispatcher.py tests/test_execution.py→ ruff format/lint, pycodestyle, pyright all passed.Notes
tests/test_router.py's "valid setup_script_path is accepted" case (asserting 201 for"scripts/setup.sh") needed no change: the issue called it out as blessing a value the runner would never execute, and after this fix that value is genuinely executed, so the assertion is now correct end-to-end.setup_script_pathintoexecute_in_contextas part of a larger rework. That PR is aimed at a different problem (POSIX-free presets), has changes requested (duplicated bootstrap + Windowsos.execv), and has been open since June, so I did not treat it as covering this issue — but if it revives, this change will need a small rebase on the same lines.setup_script_path="setup.sh"and are unaffected; git-syncedautomation.yamlvalues round-trip through the existing serializer and now take effect on the next run.HUMAN: This PR was prepared with AI assistance (code search, patch, and test execution guided by a human reviewer); the fix follows the approach sketched in issue #343.