Sandbox skill: three gaps in the `defineSandboxProxy` `allow` section

Aperta Adatta ai principianti
#511 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
84/100
Tipo di issue
Documentazione
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
typescript
Ambito
documentation

Direzione di ricerca

Leggi la sezione “Forward Matching Requests to a Proxy” in skills/sandbox/SKILL.md (righe 638–674) e confronta gli esempi con il changelog della versione 5.0.0 e packages/vercel-sandbox/src/proxy.ts citati nell’issue. Chiarisci il requisito di versione e il caso in cui manca la variabile d’ambiente, poi modifica il secondo esempio in modo che non avvolga un proxy già creato. Il lavoro è completato quando tutti e tre i punti fuorvianti sono stati corretti nello skill.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

The "Forward Matching Requests to a Proxy" section of the sandbox skill (skills/sandbox/SKILL.md, lines 638 to 674) was updated for @vercel/sandbox 5.0.0. Three things in it can mislead a reader.

1. It does not say which version it needs

The own-project rule and the allow option are new in 5.0.0, released on November 25. The skill describes them as if every version had them.

In 4.1.0 and earlier:

  • defineSandboxProxy does not check the project at all. Any sandbox with a valid token can use the proxy.
  • The second argument is the invalid-request handler, not an options object: defineSandboxProxy(handler, invalidRequestHandler?) (dist/proxy.d.ts in @vercel/[email protected]).

So on 4.x, defineSandboxProxy(handler, { allow }) never calls allow. TypeScript reports a type error, but plain JavaScript runs without complaint, and the proxy stays open to every sandbox with a valid token.

Suggested text: "The own-project rule and allow need @vercel/sandbox 5.0.0 or later. Earlier versions accept any sandbox."

2. One case is missing

Line 673 says a proxy outside Vercel has no VERCEL_PROJECT_ID. A project on Vercel that has system environment variables turned off is in the same position: it rejects every sandbox with 403. The 5.0.0 changelog and the error message both mention this case.

Suggested text, from the changelog: "A proxy with no VERCEL_PROJECT_ID, such as one outside Vercel or in a project with system environment variables disabled, rejects every sandbox until it has an allow."

3. handler means two different things

In the first snippet (line 646), handler is the finished proxy: const handler = defineSandboxProxy(...). The second snippet (line 667) then calls defineSandboxProxy(handler, { allow }).

Read together, the second snippet wraps the proxy a second time. From reading proxy.ts, the outer proxy removes the forwarding headers before it calls the inner one, so the inner one would reject every request with "Missing required proxy headers". I have not run this.

Suggested fix: show the whole call in the second snippet with the handler written inline, or give the inner function its own name.

Found while syncing the sandbox skill into vercel/vercel-plugin (vercel/vercel-plugin#467).

Lingua principale
TypeScript
Stelle
227
Fork
53
Merge medio
2g 8h
PR unite (30g)
38

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di vercel/sandbox

Tutte le issue di vercel/sandbox

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.