Skip to content

feat: plugin-spec automations from private repositories - #696

Merged
ak684 merged 2 commits into
mainfrom
alona/private-plugin-sources
Nov 5, 2026
Merged

ak684 merged 2 commits into
mainfrom
alona/private-plugin-sources

Conversation

@ak684

@ak684 ak684 commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

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, the github: shorthand and ref.

Host Source
GitHub https://x-access-token:${GITHUB_TOKEN}@github.com/org/repo.git
GitLab https://oauth2:${GITLAB_TOKEN}@gitlab.example.com/group/repo.git
Bitbucket Data Center, OAuth or project/repository token https://x-token-auth:${BITBUCKET_DATA_CENTER_TOKEN}@host/scm/proj/repo.git
Bitbucket Data Center, personal HTTP access token https://<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:

Every fetch gets references. The SDK receives LookupSecret references for only the names the source uses, never values. This applies to:

  • the create and PATCH preflight;
  • the run-as change and service-account preset pinning;
  • the dispatch preflight;
  • required plugins;
  • the agent server's 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's code and status.

Public sources behave as before.

Limits

Tests

  • 73 new tests in tests/test_plugin_secrets.py, tests/test_dispatcher_private_plugins.py and tests/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:
    • every fetch point in both modes;
    • missing, rejected, unreachable and unsupported cases, and their classification;
    • that no value appears in responses, run details, stored specs or logs.
  • 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.
  • Local mode end to end, with a real agent server 1.59.0 and a git server that only accepts its token. On main, a placeholder source is refused (422). With this change:
    • the automation is created, and its run completes at the private repository's head;
    • after the secret is deleted, the next run fails with "Missing secret" and the automation is disabled;
    • a create without the secret and one with a literal credential are refused (422);
    • the token is not in the database or the service log.
  • Cloud, on an OHE test install (agent server 1.59.0) running this PR's image at dd1a6deb, before main was merged in, with feat(automations): short-lived secret lookup references for the automations service enterprise#1205's:
    • Four private sources were created, and each run completed at its repository's head:
      • Bitbucket Data Center 9.4 with the user's OAuth token, x-token-auth:${BITBUCKET_DATA_CENTER_TOKEN};
      • Bitbucket Data Center with a repository token in a custom secret, x-token-auth:${NAME};
      • Bitbucket Data Center with the user's personal token, <username>:${NAME};
      • self-managed GitLab with the user's OAuth token, oauth2:${GITLAB_TOKEN}.
    • The stored source and each run's resolved source keep the placeholder.
    • After the custom secret was deleted, the next run failed with "Missing secret: . Add it under Settings > Secrets…", and the automation was paused with that reason.
    • Creates with a missing secret, a literal credential, a placeholder in the path and no credential were refused (422).
    • No token value, raw or percent-encoded, appears in the automation database, the automation logs or the app-server logs. The app server's audit lines name the secret, never its value.
    • The installed release refused every placeholder source (422).
    • The tokens contain no "/"; a token with "/" still needs the SDK fix above.

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 OAuth token

Bitbucket Data Center, the user's personal token in the username form: the run succeeded.

Bitbucket Data Center, the user's personal token in the username form

Self-managed GitLab, the user's OAuth token: the run succeeded.

Self-managed GitLab, the user's OAuth token

The custom secret was deleted: the next run failed, and the automation is paused with a reason that names the secret.

The custom secret was deleted

@github-actions github-actions Bot added the type: feat A new feature label Nov 5, 2026
@ak684
ak684 requested a review from all-hands-bot November 5, 2026 12:00
@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Coverage

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 all-hands-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@ak684
ak684 requested a review from all-hands-bot November 5, 2026 13:23

@all-hands-bot all-hands-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_STATUSES is unchanged: missing_secret/invalid_source/auth_failed/ref_not_found -> 422 (permanent), source_unavailable -> 502 and timeout -> 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 does httpx.get(...) + raise_for_status(), and no local secret resolver is registered in this service, so the missing_secret (404) / secret_unavailable (5xx) mapping in plugin_fetch_error still 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

@ak684
ak684 merged commit f7136b3 into main Nov 5, 2026
13 checks passed
@openhands-release-bot openhands-release-bot Bot added the released: 1.29.0 Shipped in 1.29.0 label Nov 5, 2026
@openhands-release-bot

Copy link
Copy Markdown
Contributor

🚀 Released in 1.29.0.

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

Labels

released: 1.29.0 Shipped in 1.29.0 type: feat A new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Plugin-spec automations from a private repository

2 participants