Generated client treats a declared 304 Not Modified as UnexpectedResponse

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

I maintainer di solito rispondono entro 1 giorno

@jjant ci sta già lavorando.

Dal 19/11/2026.

  • #1463 di @jjant — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
openapi, rust

Direzione di ricerca

Start by reading the response handling generated for progenitor::generate_api! and the tests for declared HTTP responses. Reproduce the issue with the supplied OpenAPI document and confirm that the generated client returns UnexpectedResponse for the empty 304 response. Done means callers can distinguish the declared 304 outcome and access its headers; pull request #1463 is already open.

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

Descrizione

A conditional GET can return 200 OK with JSON or 304 Not Modified with an empty body. With both responses declared, Progenitor 0.17.0 generates a client that returns Err(Error::UnexpectedResponse) for the 304. A caller that already has the representation has to recover a documented outcome from the catch-all error to reuse its cached copy.

Minimal OpenAPI document
{
  "openapi": "3.0.3",
  "info": {"title": "Conditional GET", "version": "1"},
  "paths": {
    "/item": {"get": {
      "operationId": "get_item",
      "parameters": [{"in": "header", "name": "If-None-Match", "schema": {"type": "string"}}],
      "responses": {
        "200": {"description": "Current item", "headers": {"ETag": {"schema": {"type": "string"}}}, "content": {"application/json": {"schema": {"type": "string"}}}},
        "304": {"description": "Not modified", "headers": {"ETag": {"schema": {"type": "string"}}}}
      }
    }}
  }
}
Reproduction
  1. Generate the client from this document using progenitor::generate_api!("openapi.json") with progenitor = "=0.17.0".
  2. Have GET /item return 200, Content-Type: application/json, ETag: "v1" and the JSON string "current". When the request includes If-None-Match: "v1", return 304 with the same ETag and an empty body.
  3. Make the two calls with the generated client.
let item = client.get_item(None).await.unwrap();
let tag = item.headers()[reqwest::header::ETAG].to_str().unwrap();
let revalidated = client.get_item(Some(tag)).await;

The first call returns the value "current". The second returns Err(Error::UnexpectedResponse(r)) with r.status() == 304 and the original ETag still present. I reproduced this on loopback with the default redirect policy.

Expected behavior

The caller can distinguish a fresh value from a declared Not Modified outcome and access its headers, without decoding an empty JSON body or matching UnexpectedResponse. The caller already holds the cached value.

Related to #451, which discusses 303 and redirect policy. A 304 completes the conditional request with the cached representation still valid. RFC 9110 §15.4.5

AI disclosure

OpenAI Codex investigated the behavior, reproduced it against Progenitor 0.17.0, and drafted this issue report.

Lingua principale
Rust
Stelle
1k
Fork
142
Merge medio
19h 13m
PR unite (30g)
16

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

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 oxidecomputer/progenitor

Tutte le issue di oxidecomputer/progenitor

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.