Skip to content

setup_script_path is validated, stored and tested — but never read; only a root setup.sh ever runs #343

Closed

Description

@VascoSch92

setup_script_path is accepted, validated, persisted and covered by tests, but no executor ever reads it. Both execution paths run a hardcoded setup.sh at the tarball root instead, so a custom tarball that names its setup script anything else silently skips its setup step and then fails in the entrypoint.

What happens

The field is honoured everywhere except where it matters:

Stage Behaviour
Request CreateAutomationRequest.setup_script_path validated by _validate_command_string — relative, no .., no shell metacharacters (schemas.py:270, :299-302)
Persistence Stored on the model (router.py:93, models.py:81, migrations/versions/001_initial_schema.py:53)
Response Echoed back in AutomationResponse (schemas.py:626)
Execution Never read. Both paths run `... && cd {work_dir} && ([ ! -f setup.sh ]

grep -rn setup_script_path openhands/ returns only the request models, the router, and the ORM model — no executor, no backend.

Why it is worth fixing rather than leaving

  • The failure is silent. The setup step is skipped, the run proceeds, and the error surfaces later as a ModuleNotFoundError (or similar) from the entrypoint — with nothing in the logs pointing at the skipped setup.
  • The test suite blesses a value that cannot work. tests/test_router.py:436-441 — "Valid setup_script_path is accepted" — asserts a 2xx for "scripts/setup.sh", a nested path the runner will never execute.
  • The documentation promises it works. skills/openhands-automation/references/custom-automation.md in OpenHands/extensions documents setup_script_path as the way to name the setup script, and its worked example passes "setup.sh" alongside an entrypoint of .venv/bin/python main.py.
  • The presets are unaffected, which is why this has gone unnoticed. They hardcode setup_script_path="setup.sh" (preset_router.py:596, :1025), matching the literal the runner looks for. Only user-authored tarballs hit the gap.

Possible resolutions

Honour the field. Use the stored value when set, keeping the current default:

setup_cmd = automation.setup_script_path or "setup.sh"
# ... && ([ ! -f "{setup_cmd}" ] || bash "{setup_cmd}") && {entrypoint}

The value is already validated against traversal, absolute paths and shell metacharacters, so interpolation is safe — quoting it keeps it that way.

Or drop it. Reject anything but "setup.sh" at the request layer, document the root-setup.sh convention, and deprecate the column.

Either way the fix should update tests/test_router.py (the nested-path case currently asserts the wrong thing) and the extensions documentation.

Found while designing catalog-shipped tarball automations in OpenHands/extensions, where the entry has to declare how its bundle is set up.

Acceptance criteria

  • A tarball automation with a stored setup_script_path (e.g. scripts/install.sh) runs that script with bash from the extracted tarball root before the entrypoint, on both the dispatcher (execute_in_context) and blocking (run_automation) paths.
  • Without a stored path, or with setup.sh, the old behaviour is kept: a root setup.sh runs if present and is skipped if absent.
  • A non-default path that is missing from the tarball fails the run before the entrypoint, with a message that names the path. It is not skipped silently.
  • Plugin-spec automations, which store the manifest's plugin-relative setup_script, keep running their bundle's root setup.sh wrapper.
  • The path is shell-quoted. Tests cover the default, custom, missing and quoting cases and the dispatcher wiring.

Reproduction on main (949c001)

Ran the automation service from main in local mode with a local agent-server. I uploaded a tarball containing main.py and scripts/install.sh, created a custom automation with "setup_script_path": "scripts/install.sh", and dispatched it. The API stores the path, but the run never executes it. The entrypoint fails with ModuleNotFoundError: dependencies missing, and the run is FAILED. Script and bundle: .pr/repro343.sh, .pr/343-bundle.

repro on main

This comment/PR was created by an AI agent (OpenHands) on behalf of Graham Neubig.

Activity

  1. added
    bug
    on Aug 17, 2026
  2. KHARSHAVARDHAN-eng commented on Sep 16, 2026

    @KHARSHAVARDHAN-eng

    Hi @VascoSch92, thanks for reporting this.

    I’d like to work on this issue. My approach would be to trace the execution paths for both local and Docker backends and update them to actually use the stored setup_script_path, while preserving setup.sh as the default.

    I’ll also update the existing tests to verify that custom nested setup scripts are executed correctly, and add/update the relevant documentation so the API behavior matches the actual execution behavior.

    If this issue is still available, I’d be happy to take it up.

  3. jpshackelford commented on Oct 19, 2026

    @jpshackelford
    Member

    Context from the UI side (Agent Canvas, OpenHands/OpenHands):

    The Canvas new-custom-automation form currently requires setup_script_path and a setup script body. Users can also edit the path, and the UI uploads the script under that name in the tarball.

    Given what this issue describes (only a root setup.sh ever runs), that is misleading. A user who enters scripts/install.sh gets a silent skip. The PR above stops requiring the path and always writes the script as root setup.sh when one is given. When a script is given, the UI sends setup_script_path: "setup.sh", and it omits the field otherwise. That is safe whichever way this issue is resolved.

    Could someone on the service side confirm which direction is intended?

    1. Honour the stored setup_script_path. The UI could then offer an optional override.
    2. Drop the field and keep the root-setup.sh convention. The UI would not send it for custom automations.

    Until this is resolved, is it fine for the UI to treat the field as ignored and never rely on it for anything other than setup.sh?

    This comment was written by an AI agent (OpenHands) on behalf of @jpshackelford.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions