Repository navigation
feat: plugin-spec automations from private repositories - #696
Conversation
|
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 gate: passed. The automations service owns plugin-spec validation and dispatch; the change stays on this side of the boundary. It builds on SDK 1.59.0 (already pinned here), which supplies placeholder expansion, LookupSecret, and error masking, and it discloses the external dependencies it still waits on (enterprise secret-lookup route, SDK URL-encoding fix, conversation-runner secret naming, docs).
Verified against the workspace code and SDK sources:
- Error classification matches the SDK. SDK 1.59.0's _ERROR_STATUSES: auth_failed/invalid_source/missing_secret/ref_not_found -> 422 (permanent); source_unavailable -> 502 and timeout -> 504 (transient). The new dispatcher handler keys on status_code with _is_retryable_http_status, so permanent failures disable and transient ones retry, and the post-sandbox handler now mirrors the preflight handler's classification (base disabled every post-sandbox PluginSpecError). Agent-server fetch failures keep the SDK's code/status.
- No secret value reaches where it must not. Stored specs and API responses keep the placeholder (asserted); the agent-server fetch payload carries only LookupSecret references (its only plaintext is the session key or a short-lived signed reference, whose holders are the intended recipients); run details, logs and tarballs are asserted value-free. LookupSecret.get_value() raising httpx.HTTPStatusError on 404/5xx is what plugin_fetch_error's missing_secret/secret_unavailable mapping relies on - confirmed in the SDK.
- Authorization is scoped to the run-as identity at every lookup: create uses run_as.user_id, PATCH uses the automation's user_id, run-as change pins with the new identity's secrets, dispatch resolves for automation.user_id, and preset service-account pinning uses run_as.user_id. The service key goes only to the app server's service route.
- Public sources are unchanged: the default lookup returns {}, an empty name-set short-circuits (cloud never calls the app server for a public create - asserted), and the source validator still rejects every literal-credential form it did before.
- Lifecycle: a preflight lookup failure happens before any sandbox exists (asserted); a post-sandbox fetch-lookup failure releases the context (asserted) with operation=fetch_plugin.
- Tests are real-path: a token-gated git server answering 401 without the credential, the SDK's real strict fetch, and a real HTTP secret store, across both fetch points and both modes, with value-leakage assertions at each boundary.
- CI: all checks on dd1a6de are green, including unit-tests.
Local run: this sandbox has no Docker, so the 784 container-fixture errors here are environmental and hit untouched files identically (e.g. tests/test_watchdog.py errors the same way). Everything runnable in the five touched files passes (79 tests), and the gzip-timestamp git-sync flake the PR reports passes on rerun.
Non-blocking observations (no action required): a 404 carrying FastAPI's default "Not Found" detail from the app server is read as route-missing (private_source_unsupported) rather than the membership message, so the wording of the unreleased enterprise route's 404 contract matters for message accuracy - both outcomes are permanent and disabling, so this only affects the error text. The dispatch path also makes two secret-lookup round trips (primary, then required plugins) where one batched call would do; the cost is negligible.
✅ APPROVED
all-hands-bot
left a comment
There was a problem hiding this comment.
This review was posted by an AI agent (OpenHands).
Scope gate: passed. The change stays inside this service's ownership (plugin-spec validation and dispatch) and now rides on SDK 1.60.0 (pinned in this rebase), which supplies placeholder expansion, LookupSecret, and error masking.
This head vs the earlier one (dd1a6de): the head is a clean merge of main at 8a5c142 (release 1.28.0, SDK 1.60.0, and #692's stop-exporting AGENT_SERVER_URL into cloud sandboxes). I verified with git diff dd1a6de ccc0abf that every core file of this feature - plugin_secrets.py, plugin_specs.py, router.py, preset_router.py, backends/base.py, tests/private_git_server.py, and the three new test files - is byte-identical to the previously reviewed head. The only PR-authored change on top of the merge is adapting main's new tests/test_cloud_run_env.py to the now-async build_execution_payload (AsyncMock patch plus awaits), which is correct.
Re-verification under SDK 1.60.0:
_ERROR_STATUSESis unchanged:missing_secret/invalid_source/auth_failed/ref_not_found-> 422 (permanent),source_unavailable-> 502 andtimeout-> 504 (transient). The dispatcher's status-keyed classification therefore still disables exactly the permanent cases and retries exactly the transient ones.LookupSecret.get_value()still doeshttpx.get(...)+raise_for_status(), and no local secret resolver is registered in this service, so themissing_secret(404) /secret_unavailable(5xx) mapping inplugin_fetch_errorstill holds.
Merge correctness: #692 removed AGENT_SERVER_URL from cloud runs; the merged head carries that with an updated dispatcher comment and AGENTS.md env table, and the plugin-secrets hunks sit cleanly beside it - the two changes touch disjoint concerns (env export vs. plugin fetch lookups). CI is fully green on ccc0abfa, including unit-tests (which covers the Docker-fixture tests I cannot run here).
Local run: no Docker in this sandbox, so container-fixture errors are environmental and hit untouched files identically. All 79 runnable tests in the PR's five test files pass, and the non-Docker tests of test_cloud_run_env.py (13) pass too.
Acceptance evidence in the PR description is now concrete: local mode end-to-end against a real token-gated git server (create, run at head, missing-secret run fails naming the secret and disables the automation, literal credential and secret-less create refused 422, no token in DB or logs), and cloud runs on an OHE test install across four private source forms (Bitbucket Data Center OAuth and custom repo token, personal token in the username form, self-managed GitLab oauth2), with the placeholder preserved in stored and resolved sources and no token value, raw or percent-encoded, in any log. The stated limits (SDK "/" token fix, conversation-runner secret naming, docs) are disclosed rather than hidden.
Non-blocking observations (unchanged from the earlier head, no action required): a 404 carrying FastAPI's default "Not Found" detail from the app server is read as route-missing rather than the membership message, so the unreleased enterprise route's 404 contract wording matters for message accuracy only (both outcomes are permanent); and the dispatch path performs two secret-lookup round trips (primary, then required plugins) where one batched call would do.
✅ APPROVED
|
🚀 Released in 1.29.0. |
Fixes #694 (Linear OSS-15139).
Why
A plugin-spec automation could not use a plugin from a private repository. The service fetched the plugin with no credential and rejected any credential in the source. Creating one failed with 422 (
auth_failed), and a run of an existing one failed and disabled the automation.What changes
Source contract. A private source names its credential with a
${NAME}placeholder as the URL user name or password. The source is stored and returned with the placeholder, never the value. Literal credentials are still rejected, and so are placeholders anywhere else: host, path, query, thegithub:shorthand andref.https://x-access-token:${GITHUB_TOKEN}@github.com/org/repo.githttps://oauth2:${GITLAB_TOKEN}@gitlab.example.com/group/repo.githttps://x-token-auth:${BITBUCKET_DATA_CENTER_TOKEN}@host/scm/proj/repo.githttps://<username>:${NAME}@host/scm/proj/repo.git(the token owner's user name)Where the value comes from, always for the user or service account the automation runs as:
/api/settings/secrets/{name}).Every fetch gets references. The SDK receives
LookupSecretreferences for only the names the source uses, never values. This applies to:POST /api/plugins/fetch, with fresh references after the sandbox starts.No value reaches logs, errors, run details, stored specs or API responses.
Errors. A missing secret, rejected credentials (
auth_failed), a malformed URL and a refused lookup are permanent: they disable the automation, and the message names the secret. An unreachable secret store is transient. Required-plugin and agent-server fetch failures now keep the SDK'scodeand status.Public sources behave as before.
Limits
invalid_sourcewith a hint. The fix is fix(plugin): percent-encode secret values in plugin source URL user info software-agent-sdk#6511. It needs an SDK release after 1.60.0 and a bump here.openhands-automationskill and product docs still need the placeholder and the table above.Tests
tests/test_plugin_secrets.py,tests/test_dispatcher_private_plugins.pyandtests/test_router_private_plugins.py. They run a real git server that only accepts its token, the SDK's real strict fetch, and a real secret store. They cover:uv run python -m pytest tests/ -n 6, with main at 1.28.0 merged in (SDK 1.60.0): 2626 passed, 7 skipped, none failed.dd1a6deb, before main was merged in, with feat(automations): short-lived secret lookup references for the automations service enterprise#1205's:x-token-auth:${BITBUCKET_DATA_CENTER_TOKEN};x-token-auth:${NAME};<username>:${NAME};oauth2:${GITLAB_TOKEN}.Screenshots from the test install (hosts and identities masked):
Bitbucket Data Center, the user's OAuth token: the run succeeded.
Bitbucket Data Center, the user's personal token in the username form: the run succeeded.
Self-managed GitLab, the user's OAuth token: the run succeeded.
The custom secret was deleted: the next run failed, and the automation is paused with a reason that names the secret.