Repository navigation
test(cache): cover rejected remote cache uploads - #810
Merged
Merged
Conversation
fspy benchmarklinuxmacoswindows |
wan9chi
force-pushed
the
remote-cache-e2e-rejected-uploads
branch
from
October 6, 2026 02:48
f5802bf to
0514599
Compare
Add e2e cases for uploads that the backend rejects, like the public cache service would: a token from a pull request's job, which the write policy doesn't allow, and an upload without a token from outside GitHub Actions. Both tasks succeed, and the run reports the upload as failed with the backend's message. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
wan9chi
force-pushed
the
remote-cache-e2e-rejected-uploads
branch
from
November 7, 2026 10:01
0514599 to
4a66284
Compare
wan9chi
marked this pull request as ready for review
November 7, 2026 11:02
wan9chi
added a commit
that referenced
this pull request
Nov 7, 2026
…rker (#811) ## Motivation The remote cache e2e cases ran against a Node file backend that imitated a remote cache server's protocol and write policy. #807 → #810 put the test infrastructure in place against that backend: one backend per case, a tap for the request log, blob numbering, `corrupt-blob`, and a GitHub Actions stand-in. Vite+'s Cloudflare implementation now lives in [voidzero-dev/vite-plus-remote-cache-cloudflare](https://github.com/voidzero-dev/vite-plus-remote-cache-cloudflare), moved there from #718, and the cases can run against it: a real, independently written server for the protocol. ## Changes - **Backend.** Behind the same `remote-cache-server` commands, the backend is that Worker at a pinned commit, a git dependency of `vite-task-tools`, running in workerd through Miniflare: - The Worker runs with the compatibility settings, bindings, and limits that wrangler reads from its `wrangler.jsonc`. Its namespaces are limited to the endpoint's. - As in a deployment, every migration is applied with wrangler's SQL splitter, and the namespace is registered for the endpoint and the test repository. - The Worker fetches GitHub's key set to verify upload tokens and gets the stand-in's key instead. Any other outbound request fails. - `corrupt-blob` replaces the blob's object in R2 and its recorded size. - **Workspace.** The workspace allows esbuild's and workerd's build scripts, which a root `pnpm install` otherwise rejects. `@cloudflare/workers-types` provides Miniflare's binding types. - **Removed** the file backend and its `@fastify/busboy` dependency. - **musl.** The cases that use the backend are skipped on musl, because workerd's prebuilt binaries require glibc. - **Restarts.** `start` empties the Worker's D1 database and R2 bucket in `remote-cache/state/` first, since the migrations assume a new database. - **Tap.** The Worker rejects an upload by its headers, answering before it reads the body, and then closes the connection. The tap no longer counts the failure to send the rest of that body as a backend problem once the whole response has arrived. With a large rejected upload, `stop` failed every time before this change. **None of the snapshots change.** Apart from that tap fix, the daemon, the tap, the CLI, and the stand-in are untouched. Only the backend behind them is different. Stacked on #810. 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Test-infra swap with heavier Node deps and platform limits (no musl); behavior now depends on an external Worker package and Miniflare, though production client code is unchanged. > > **Overview** > Replaces the in-repo **Node file backend** (`state.json` + blob files) with **Vite+'s pinned Cloudflare remote cache Worker**, started locally via **Miniflare/workerd**. `startBackend` bundles the Worker with esbuild, applies D1 migrations, registers the test namespace, mocks GitHub JWKS for upload tokens, and persists state under `remote-cache/state/` (cleared on each `start`). **`corrupt-blob`** now writes corrupt bytes into **R2** and updates the recorded blob size. > > **Dependencies:** adds `miniflare`, `wrangler`, `esbuild`, and the git-pinned Worker package; removes `@fastify/busboy`. Workspace **`allowBuilds`** enables **workerd** install scripts. > > **E2E:** every snapshot case that starts `remote-cache-server` gets `cfg = 'not(target_env = "musl")'` because workerd needs glibc. README documents the new backend. > > **Tap fix:** when the Worker rejects an upload from headers and closes the connection before the body is sent, the proxy no longer treats the resulting write error as a backend failure once the response is complete—so `stop` stays reliable on large rejected uploads. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 7ddfbd5. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
With the write policy in place from #809, the e2e cases can cover the uploads Vite+'s Cloudflare remote cache rejects. A developer running
--remote-cache=read-writeoutside GitHub Actions, or a job for a pull request, should still see their task succeed and be told why nothing was uploaded.Changes
pull_request_upload: a pull request's token doesn't satisfy the write policy. The upload gets403, and the details showWrite not permitted.upload_without_token: an upload from outside GitHub Actions has no token. It gets401, and the details showInvalid credentials.Both tasks succeed. The snapshots come from the file backend here. The backend switch later in this stack must leave them unchanged, which shows that the emulated policy matches the Worker's.
Stacked on #809.
🤖 Generated with Claude Code
Note
Low Risk
Test and snapshot additions only; no runtime or policy logic changes.
Overview
Adds two ignored remote-cache e2e scenarios and matching snapshot fixtures so upload rejections under the write policy are covered end-to-end.
pull_request_uploadrunsvt run buildwith read-write remote cache and a pull-request GitHub Actions token; the store call gets 403, the build still succeeds, andvt run --last-detailsshows Write not permitted.upload_without_tokenruns the same flow outside the--github-actionswrapper (no OIDC token); the backend returns 401 with Invalid credentials in the details while the task completes successfully.Both cases follow the existing
remote-cache-serverstart/run/stop pattern and useVP_RUN_INTERNAL_HIDE_PENDING_UPLOADSfor stable output.Reviewed by Cursor Bugbot for commit 4a66284. Bugbot is set up for automated code reviews on this repo. Configure here.