Repository navigation
feat(plugin): add strict plugin fetch preflight - #5987
Conversation
Co-authored-by: openhands <openhands@all-hands.dev>
REST API breakage checks (OpenAPI) — ✅ PASSEDResult: ✅ PASSED |
Coverage Report •
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
Co-authored-by: openhands <openhands@all-hands.dev>
all-hands-bot
left a comment
There was a problem hiding this comment.
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:
-
An unparseable
source(after${VAR}expansion) raisesExtensionFetchErrorfromparse_extension_source, which neither the router'sexcept PluginSourceErrornorpreflight_pluginclassifies. The endpoint answers500 Internal Server Errorinstead of the documented422, and the unhandled-exception handler echoesstr(exc)in the responseexceptionfield — so a source like"${PLUGIN_TOKEN}"with aStaticSecretreturns 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_pluginlikewise propagates a bareExtensionFetchErrorrather thanPluginSourceError, so existingexcept PluginSourceError/except PluginFetchErrorcallers miss it. -
_store_pinned_checkoutcopies the fetched checkout including.git, andgit 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-bearingfile://source:.git/configretainedx-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
left a comment
There was a problem hiding this comment.
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:
-
parse_extension_sourceis now wrapped and mapsExtensionFetchErrortoPluginSourceError("invalid_source", ...)withfrom None. I reproduced the previous failures:POST /plugins/fetchwithnot-a-real-source,github:oops, orftp://...now returns422with{"code":"invalid_source","message":"Invalid plugin source."}instead of500, and asource="${TOKEN}"with aStaticSecretreturns the structured error with the expanded value absent from the body.preflight_pluginlikewise raisesPluginSourceError(code="invalid_source"). -
_store_pinned_checkoutnow copies withignore=shutil.ignore_patterns(".git"). Verified that a credential-bearingfile://x-access-token:${TOKEN}@...source no longer persists.git/config(or any credential) in the pinned cache, that the pinned path is still reused byfetch_plugin_with_resolution, and thatPlugin.loadsucceeds 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>
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
preflight_plugin(...),PluginSourceError, andCheckedPlugintoopenhands.sdk.pluginwith strict secret expansion, structured error codes, temporary checkout cleanup, and raw manifest/skills/commands metadata.POST /api/plugins/fetchvia the existing/pluginsrouter to fetch and pin a plugin into an immutable commit-SHA cache path without installing or enabling it.fetch_plugin_with_resolution(...)when a commit SHA was already materialized by the strict resolver, and fixed plugin error wording so URL text such asextensions-privateis not rewritten.REST API contract changes
Compared with base OpenAPI
1a0fd91ad03dfor public/api/**paths.Issue Number
Refs #5748
How to Test
Validated with:
Results:
16 passedVideo/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
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
eclipse-temurin:17-jdkpython-node-runtimepython-node-runtimepython-node-runtimegolang:1.21-bookwormPull (multi-arch manifest)
# Each variant is a multi-arch manifest supporting both amd64 and arm64 docker pull ghcr.io/openhands/agent-server:9064309-pythonRun
All tags pushed for this build
About Multi-Architecture Support
9064309-python) is a multi-arch manifest supporting both amd64 and arm649064309-python-amd64) are also available if needed