REST downloads from the S3 backend drop ETag and Cache-Control on 304 responses

Aperta
#1,649 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@hsusul ci sta già lavorando.

Dal 3/11/2026.

  • #1653 di @hsusul — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
aws, typescript
Ambito
api, backend

Direzione di ricerca

Start with Renderer.render() and its error branch, then compare the S3 backend’s 304 handling with the file backend’s setHeaders() path and the existing S3 protocol GetObject handling. Reproduce with a stub upstream returning 304 and ETag, Cache-Control, and Last-Modified; done means the REST download’s 304 preserves the headers expected for the corresponding 200 response. Pull request #1653 is already open for this issue.

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

Descrizione

Bug report

With the S3 storage backend, a REST object download that revalidates with If-None-Match gets a bare 304 Not Modified. The response has no ETag, Cache-Control or Last-Modified. RFC 9110 section 15.4.5 requires a 304 to carry the ETag and Cache-Control that a 200 would have sent.

The AWS SDK throws on a 304, so Renderer.render() handles it in its error branch. That branch only sets Vary before it sends the 304. The file backend returns its 304 as a value, so it goes through setHeaders() and keeps these headers. The S3 protocol GetObject path already copies them from the SDK error's raw response.

To reproduce

  1. Run Storage with STORAGE_BACKEND=s3 and upload bucket/object.txt to a public bucket.
  2. GET /object/public/bucket/object.txt and note the ETag.
  3. Send the same request with If-None-Match: <that ETag>.

A unit test that points S3Backend at a stub upstream, which answers the conditional request with 304 plus ETag, Cache-Control and Last-Modified, gets this at upstream b74897cf:

statusCode: 304
etag: undefined

Expected behavior

The 304 carries the upstream ETag and Last-Modified, and the same Cache-Control (or signed URL Expires) that the 200 response would have. Browsers and CDNs then keep the stored validator and refresh its freshness instead of revalidating on every request.

Scope

This covers the REST renderer for downloads through the S3 backend. #1511/#1512 cover response overrides on S3 protocol 304s, and #1607 covers HeadObject conditionals.

Lingua principale
TypeScript
Stelle
1.4k
Fork
319
Merge medio
1g 11h
PR unite (30g)
95

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 supabase/storage

Tutte le issue di supabase/storage

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.