Skip to content

Fetch configure extensions by reference from the metro API - #502

Open
masnwilliams wants to merge 6 commits into
mainfrom
hypeship/configure-extension-refs
Open

masnwilliams wants to merge 6 commits into
mainfrom
hypeship/configure-extension-refs

Conversation

@masnwilliams

@masnwilliams masnwilliams commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

/chromium/configure can now take an extensions.ref part instead of an uploaded zip. Each part names an extension, its sha256 and a grant. kernel-images-api fetches the archive from the metro API's extension cache (GET {KERNEL_METRO_API_BASE_URL}/extension-archive/{name}), authenticating with its instance token and the grant. It verifies the checksum and then handles the extension exactly like an uploaded one.

This lets the control plane skip downloading, decrypting and uploading extension archives on every browser create. The caller and the metro API side are in kernel/kernel (linked below).

Behavior

  • Fetch timing: references are fetched in parallel after the multipart body is parsed and before anything is applied. The configure mode (restart vs prefer_cdp) is decided afterwards, from the fetched extensions.
  • Failure handling: any fetch failure returns 500 with the new step extension_fetch and leaves the instance unchanged. The caller can resend the same request with the archives uploaded. A failure can be a non-200, a checksum mismatch, an archive over 64 MB, or a missing metro URL or instance token.
  • Older images: images without this change reject the part with 400 unknown form field "extensions.ref", also before applying anything.
  • Extension cap: a request may carry at most 20 extensions, uploaded and referenced together. This is the same cap as the upload endpoint, and it now applies to uploads on /chromium/configure too, which had no limit before. The API already caps extensions per browser at 20.
  • Identity: the metro URL and instance token come from the existing instanceIdentityProvider, so a forked VM uses the identity it was given after boot.
  • Metro URL fallback: only proxy-v3 variants boot with KERNEL_METRO_API_BASE_URL, while every VM boots with SESSION_INTEL_URL, served by the same metro API. The fetcher falls back to it, so non-forked VMs without the metro URL can fetch too. Other users of the metro URL (the WebAuthn hook) are unchanged.

Changes

  • lib/extensionfetch: the fetch client (single attempt, 30s timeout, sha256 verify, size cap, 0600 output file).
  • chromium_configure.go: parse extensions.ref (8 KiB cap, validated name and checksum), then fetchExtensionRefs before configure.
  • openapi.yaml: documents the part and adds extension_fetch to the error step enum. lib/oapi is regenerated; the only changes are the new enum constant and the embedded spec.
  • api.New takes the fetcher; main.go wires it to the instance identity.

Testing

  • go test -race ./cmd/api/... ./lib/extensionfetch/ ./lib/oapi/ passes.
  • New tests: parsing and validation of refs; parallel fetch merged into extItems; a failing fetch reported as extension_fetch with nothing applied; the fetch client's headers, checksum, refusal and unconfigured cases.
  • make oapi-generate steps on the base commit reproduce the committed oapi.go byte for byte. The regenerated file in this PR comes from the same steps.
  • Not run here: e2e tests against built images.

Note

Medium Risk
Adds network dependency and auth to configure before Chromium changes; failures are isolated but extension fetch affects a core session-setup path.

Overview
Chromium configure can now reference extensions instead of uploading zips: multipart extensions.ref parts carry JSON (name, sha256, grant). The API downloads archives from the metro /extension-archive/{name} endpoint (new lib/extensionfetch client with bearer token, grant header, checksum and 64 MiB checks), merges them into the existing extension flow, and runs fetches in parallel before any configure side effects. Failures return 500 with step extension_fetch and leave the instance unchanged.

Wiring: ApiService takes an extensionFetcher; main builds it from instance identity with extensionFetchBaseURL (metro API URL or SESSION_INTEL_URL). The combined upload+reference count is capped at the existing 20 extension limit on configure. OpenAPI documents the new field and error step.

Reviewed by Cursor Bugbot for commit fe9ff8c. Bugbot is set up for automated code reviews on this repo. Configure here.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

/chromium/configure accepts extensions.ref parts naming an extension, its
sha256 and a grant. kernel-images-api fetches each from the metro API's
extension cache with its instance token before applying anything, verifies
the checksum, and treats it as an uploaded extension. A failed fetch returns
500 with step extension_fetch and leaves the instance unchanged, so the
caller can resend the request with the archives uploaded.
@masnwilliams
masnwilliams force-pushed the hypeship/configure-extension-refs branch from 1f6fbb0 to edae3ce Compare November 2, 2026 19:01
Each reference starts a fetch, so limit references plus uploaded extensions
to the same 20 the upload endpoint allows.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

Count uploaded and referenced extensions together once parsing finishes, so
part order cannot get more than 20 through.
Only proxy-v3 variants boot with KERNEL_METRO_API_BASE_URL. Every VM
boots with SESSION_INTEL_URL, which the same metro API serves, so a
non-forked VM without the metro URL can still fetch extensions instead
of sending every create down the upload fallback.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 558a347. Configure here.

Comment thread server/cmd/api/instance_identity.go Resolved

This branch has not been deployed

No deployments
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.

1 participant