Skip to content

feat(plugin): add strict plugin fetch preflight - #5987

Merged
malhotra5 merged 5 commits into
mainfrom
feat/strict-plugin-fetch
Oct 16, 2026
Merged

malhotra5 merged 5 commits into
mainfrom
feat/strict-plugin-fetch

Conversation

@malhotra5

@malhotra5 malhotra5 commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

HUMAN:

I've tested this in the automation service and verified that plugins can be validated and loaded as expected.


AGENT:

Why

Issue #5748 asks for a strict plugin source resolver that can validate automation plugins before a sandbox is created, and for an agent-server endpoint that fetches and pins a plugin without installing it. The existing cached plugin fetch path can silently fall back to stale revisions when fetch or checkout fails, which is unsafe for automation bootstrap.

Summary

  • Added preflight_plugin(...), PluginSourceError, and CheckedPlugin to openhands.sdk.plugin with strict secret expansion, structured error codes, temporary checkout cleanup, and raw manifest/skills/commands metadata.
  • Added POST /api/plugins/fetch via the existing /plugins router to fetch and pin a plugin into an immutable commit-SHA cache path without installing or enabling it.
  • Added pinned-cache reuse for fetch_plugin_with_resolution(...) when a commit SHA was already materialized by the strict resolver, and fixed plugin error wording so URL text such as extensions-private is not rewritten.

REST API contract changes

Compared with base OpenAPI 1a0fd91ad03d for public /api/** paths.

--- base public OpenAPI
+++ head public OpenAPI
@@ -149,0 +150 @@
+operation POST /api/plugins/fetch operationId=fetch_plugin_endpoint_api_plugins_fetch_post
@@ -408,0 +410 @@
+requestBody POST /api/plugins/fetch application/json required=true schema=FetchPluginRequest
@@ -756,0 +759,4 @@
+response POST /api/plugins/fetch 200 application/json schema=FetchPluginResponse
+response POST /api/plugins/fetch 422 no-content
+response POST /api/plugins/fetch 502 no-content
+response POST /api/plugins/fetch 504 no-content
@@ -1630,0 +1637,14 @@
+schema FetchPluginRequest property ref optional schema=anyOf=[type="string",type="null"]
+schema FetchPluginRequest property repo_path optional schema=anyOf=[type="string",type="null"]
+schema FetchPluginRequest property secrets optional schema=type="object" additionalProperties=SecretSource-Input
+schema FetchPluginRequest property source required schema=type="string" minLength=1
+schema FetchPluginRequest property timeout optional schema=type="integer" default=60 minimum=1.0 maximum=600.0
+schema FetchPluginRequest type="object"
+schema FetchPluginResponse property commands required schema=type="array" items=type="string"
+schema FetchPluginResponse property manifest required schema=type="object" additionalProperties=JSONValue
+schema FetchPluginResponse property path required schema=type="string"
+schema FetchPluginResponse property repo_path required schema=anyOf=[type="string",type="null"]
+schema FetchPluginResponse property resolved_ref required schema=anyOf=[type="string",type="null"]
+schema FetchPluginResponse property skills required schema=type="array" items=type="string"
+schema FetchPluginResponse property source required schema=type="string"
+schema FetchPluginResponse type="object"
@@ -1934,0 +1955 @@
+schema JSONValue anyOf=[type="string",type="integer",type="number",type="boolean",type="array" items=JSONValue,type="object" additionalProperties=JSONValue,type="null"]
@@ -2094 +2114,0 @@
-schema LaunchedAgentProfile property inline optional schema=type="boolean" default=false
@@ -2767 +2786,0 @@
-schema StartConversationRequest property agent_profile optional schema=anyOf=[oneOf=[OpenHandsAgentProfile,ACPAgentProfile],type="null"]

Issue Number

Refs #5748

How to Test

Validated with:

uv run pytest tests/sdk/plugin/test_plugin_strict_fetch.py tests/agent_server/test_plugins_router.py -q
uv run pre-commit run --files openhands-agent-server/openhands/agent_server/plugins_router.py openhands-agent-server/openhands/agent_server/plugins_service.py openhands-sdk/openhands/sdk/plugin/__init__.py openhands-sdk/openhands/sdk/plugin/fetch.py openhands-sdk/openhands/sdk/plugin/paths.py openhands-sdk/openhands/sdk/plugin/strict_fetch.py tests/agent_server/test_plugins_router.py tests/sdk/plugin/test_plugin_strict_fetch.py
git diff --check

Results:

  • 16 passed
  • pre-commit passed for all changed files
  • whitespace check passed

Video/Screenshots

No UI changes. The API behavior is covered by the focused router tests in tests/agent_server/test_plugins_router.py.

Design Doc

Not added for this initial implementation slice.

Type

  • Bug fix
  • Feature
  • Refactor
  • Breaking change
  • Docs / chore

Notes

This is an initial implementation slice for #5748 rather than a claim that every acceptance criterion is fully complete. Follow-ups likely include docs updates and broader live/private-repository coverage for provider-specific authentication classification.

This PR description was created by an AI agent (OpenHands) on behalf of the user.

@malhotra5 can click here to continue refining the PR


🐳 Agent Server images for this PR — GHCR package, pull/run commands, and all pushed tags (click to expand)

• GHCR package: https://github.com/OpenHands/agent-sdk/pkgs/container/agent-server

Variants & Base Images

Variant Architectures Base Image Docs / Tags
java amd64, arm64 eclipse-temurin:17-jdk Link
python-slim amd64, arm64 python-node-runtime Link
python-minimal amd64, arm64 python-node-runtime Link
python amd64, arm64 python-node-runtime Link
golang amd64, arm64 golang:1.21-bookworm Link

Pull (multi-arch manifest)

# Each variant is a multi-arch manifest supporting both amd64 and arm64
docker pull ghcr.io/openhands/agent-server:9064309-python

Run

docker run -it --rm \
  -p 8000:8000 \
  --name agent-server-9064309-python \
  ghcr.io/openhands/agent-server:9064309-python

All tags pushed for this build

ghcr.io/openhands/agent-server:9064309-golang-amd64
ghcr.io/openhands/agent-server:906430917242d7f6cb015c6413c6595b61945943-golang-amd64
ghcr.io/openhands/agent-server:feat-strict-plugin-fetch-golang-amd64
ghcr.io/openhands/agent-server:9064309-golang_tag_1.21-bookworm-amd64
ghcr.io/openhands/agent-server:9064309-golang-arm64
ghcr.io/openhands/agent-server:906430917242d7f6cb015c6413c6595b61945943-golang-arm64
ghcr.io/openhands/agent-server:feat-strict-plugin-fetch-golang-arm64
ghcr.io/openhands/agent-server:9064309-golang_tag_1.21-bookworm-arm64
ghcr.io/openhands/agent-server:9064309-java-amd64
ghcr.io/openhands/agent-server:906430917242d7f6cb015c6413c6595b61945943-java-amd64
ghcr.io/openhands/agent-server:feat-strict-plugin-fetch-java-amd64
ghcr.io/openhands/agent-server:9064309-eclipse-temurin_tag_17-jdk-amd64
ghcr.io/openhands/agent-server:9064309-java-arm64
ghcr.io/openhands/agent-server:906430917242d7f6cb015c6413c6595b61945943-java-arm64
ghcr.io/openhands/agent-server:feat-strict-plugin-fetch-java-arm64
ghcr.io/openhands/agent-server:9064309-eclipse-temurin_tag_17-jdk-arm64
ghcr.io/openhands/agent-server:9064309-python-amd64
ghcr.io/openhands/agent-server:906430917242d7f6cb015c6413c6595b61945943-python-amd64
ghcr.io/openhands/agent-server:feat-strict-plugin-fetch-python-amd64
ghcr.io/openhands/agent-server:9064309-python-node-runtime-amd64
ghcr.io/openhands/agent-server:9064309-python-arm64
ghcr.io/openhands/agent-server:906430917242d7f6cb015c6413c6595b61945943-python-arm64
ghcr.io/openhands/agent-server:feat-strict-plugin-fetch-python-arm64
ghcr.io/openhands/agent-server:9064309-python-node-runtime-arm64
ghcr.io/openhands/agent-server:9064309-python-minimal-amd64
ghcr.io/openhands/agent-server:906430917242d7f6cb015c6413c6595b61945943-python-minimal-amd64
ghcr.io/openhands/agent-server:feat-strict-plugin-fetch-python-minimal-amd64
ghcr.io/openhands/agent-server:9064309-python-node-runtime-minimal-amd64
ghcr.io/openhands/agent-server:9064309-python-minimal-arm64
ghcr.io/openhands/agent-server:906430917242d7f6cb015c6413c6595b61945943-python-minimal-arm64
ghcr.io/openhands/agent-server:feat-strict-plugin-fetch-python-minimal-arm64
ghcr.io/openhands/agent-server:9064309-python-node-runtime-minimal-arm64
ghcr.io/openhands/agent-server:9064309-python-slim-amd64
ghcr.io/openhands/agent-server:906430917242d7f6cb015c6413c6595b61945943-python-slim-amd64
ghcr.io/openhands/agent-server:feat-strict-plugin-fetch-python-slim-amd64
ghcr.io/openhands/agent-server:9064309-python-node-runtime-slim-amd64
ghcr.io/openhands/agent-server:9064309-python-slim-arm64
ghcr.io/openhands/agent-server:906430917242d7f6cb015c6413c6595b61945943-python-slim-arm64
ghcr.io/openhands/agent-server:feat-strict-plugin-fetch-python-slim-arm64
ghcr.io/openhands/agent-server:9064309-python-node-runtime-slim-arm64
ghcr.io/openhands/agent-server:9064309-golang
ghcr.io/openhands/agent-server:906430917242d7f6cb015c6413c6595b61945943-golang
ghcr.io/openhands/agent-server:feat-strict-plugin-fetch-golang
ghcr.io/openhands/agent-server:9064309-golang_tag_1.21-bookworm
ghcr.io/openhands/agent-server:9064309-java
ghcr.io/openhands/agent-server:906430917242d7f6cb015c6413c6595b61945943-java
ghcr.io/openhands/agent-server:feat-strict-plugin-fetch-java
ghcr.io/openhands/agent-server:9064309-eclipse-temurin_tag_17-jdk
ghcr.io/openhands/agent-server:9064309-python-minimal
ghcr.io/openhands/agent-server:906430917242d7f6cb015c6413c6595b61945943-python-minimal
ghcr.io/openhands/agent-server:feat-strict-plugin-fetch-python-minimal
ghcr.io/openhands/agent-server:9064309-python-node-runtime-minimal
ghcr.io/openhands/agent-server:9064309-python-slim
ghcr.io/openhands/agent-server:906430917242d7f6cb015c6413c6595b61945943-python-slim
ghcr.io/openhands/agent-server:feat-strict-plugin-fetch-python-slim
ghcr.io/openhands/agent-server:9064309-python-node-runtime-slim
ghcr.io/openhands/agent-server:9064309-python
ghcr.io/openhands/agent-server:906430917242d7f6cb015c6413c6595b61945943-python
ghcr.io/openhands/agent-server:feat-strict-plugin-fetch-python
ghcr.io/openhands/agent-server:9064309-python-node-runtime

About Multi-Architecture Support

  • Each variant tag (e.g., 9064309-python) is a multi-arch manifest supporting both amd64 and arm64
  • Docker automatically pulls the correct architecture for your platform
  • Individual architecture tags (e.g., 9064309-python-amd64) are also available if needed

Co-authored-by: openhands <openhands@all-hands.dev>
@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

REST API breakage checks (OpenAPI) — ✅ PASSED

Result: ✅ PASSED

Action log

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Coverage

Coverage Report •
FileStmtsMissCoverMissing
openhands-agent-server/openhands/agent_server
   agent_profiles_router.py2411395%99, 185, 189, 193, 212, 215, 310, 314, 317–318, 526, 566–567
   plugins_router.py134497%338–339, 343–344
   plugins_service.py119893%302, 351–352, 367, 371, 378–380
openhands-sdk/openhands/sdk/plugin
   fetch.py41685%37–38, 40, 44, 46, 51
   strict_fetch.py2005473%62, 79, 140–141, 145–146, 222–224, 269–275, 289, 307–310, 321, 375–378, 383–384, 388–391, 399–400, 410–411, 415–420, 431, 434, 447, 450, 467–469, 493–495, 499, 504
openhands-sdk/openhands/sdk/profiles
   agent_profile.py140596%413, 491, 497, 502, 530
TOTAL50536847683% 

Co-authored-by: openhands <openhands@all-hands.dev>
@malhotra5
malhotra5 marked this pull request as ready for review October 15, 2026 01:47

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

Copy link
Copy Markdown
Collaborator

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).

Reviewed head 10e032d86363a5ced83270dc0a7aa81564e31959 (main <- feat/strict-plugin-fetch, +882/-1). Focused tests pass locally (uv run pytest tests/sdk/plugin/test_plugin_strict_fetch.py tests/agent_server/test_plugins_router.py -q -> 16 passed). The linked issue #5748 is open with only the enhancement label; the Validate PR description check is failing because #5748 carries neither ready-for-dev nor a pre-rollout creation date.

The strict resolver is a good addition and the pinned-cache path is sound, but the new POST /api/plugins/fetch endpoint and preflight_plugin() do not satisfy the error-contract and secret-handling requirements the issue states for the same inputs. Two demonstrated findings are attached inline:

  1. An unparseable source (after ${VAR} expansion) raises ExtensionFetchError from parse_extension_source, which neither the router's except PluginSourceError nor preflight_plugin classifies. The endpoint answers 500 Internal Server Error instead of the documented 422, and the unhandled-exception handler echoes str(exc) in the response exception field — so a source like "${PLUGIN_TOKEN}" with a StaticSecret returns the raw expanded secret in the HTTP body. The issue requires each error case to map to a listed status with structured {code, message}, and that results never contain an expanded secret. preflight_plugin likewise propagates a bare ExtensionFetchError rather than PluginSourceError, so existing except PluginSourceError / except PluginFetchError callers miss it.

  2. _store_pinned_checkout copies the fetched checkout including .git, and git remote add origin <url> has already written the credential-bearing URL into .git/config. The immutable pinned cache under ~/.openhands/cache/plugins/.../resolved-refs/<sha> then contains the expanded token in plaintext for the lifetime of the cache. Verified with a credential-bearing file:// source: .git/config retained x-access-token:SUPERSECRET@.... This conflicts with the repository rule that secrets must not be persisted in plaintext and with the issue's "results never contain an expanded value" criterion.

Because finding 1 changes an observable API contract and discloses secrets in an HTTP response, this is a material defect; I am not approving this head.

🔄 CHANGES REQUESTED

Co-authored-by: openhands <openhands@all-hands.dev>

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

Copy link
Copy Markdown
Collaborator

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).

Re-reviewed head 97845e0d628a514252fc08765d97f301949fc3a7 (fix(plugin): sanitize strict fetch failures), which moved since the previous review. Both findings from that review are addressed and verified on this head:

  1. parse_extension_source is now wrapped and maps ExtensionFetchError to PluginSourceError("invalid_source", ...) with from None. I reproduced the previous failures: POST /plugins/fetch with not-a-real-source, github:oops, or ftp://... now returns 422 with {"code":"invalid_source","message":"Invalid plugin source."} instead of 500, and a source="${TOKEN}" with a StaticSecret returns the structured error with the expanded value absent from the body. preflight_plugin likewise raises PluginSourceError(code="invalid_source").

  2. _store_pinned_checkout now copies with ignore=shutil.ignore_patterns(".git"). Verified that a credential-bearing file://x-access-token:${TOKEN}@... source no longer persists .git/config (or any credential) in the pinned cache, that the pinned path is still reused by fetch_plugin_with_resolution, and that Plugin.load succeeds on the .git-less pinned checkout.

Focused tests pass locally on this head (uv run pytest tests/sdk/plugin tests/agent_server/test_plugins_router.py -q -> 396 passed; the two strict-fetch files -> 19 passed). The new regression tests cover both cases. All GitHub Actions checks for this head are green (Validate PR description, unresolved-review-threads, OpenAPI/agent-server/security/pre-commit, build and image jobs), and linked issue #5748 now carries ready-for-dev.

No material findings remain. The change stays within this repository's ownership (SDK pre-flight + agent-server endpoint) and matches the direction in #5748.

✅ APPROVED

Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: openhands <openhands@all-hands.dev>
@malhotra5
malhotra5 merged commit db9c54b into main Oct 16, 2026
54 of 55 checks passed
@malhotra5
malhotra5 deleted the feat/strict-plugin-fetch branch October 16, 2026 01:25
@github-actions github-actions Bot mentioned this pull request Oct 16, 2026
1 of 7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants