Generated client treats a declared 304 Not Modified as UnexpectedResponse
I maintainer di solito rispondono entro 1 giorno
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
- Ambito
- backend-api-design
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
- Generate the client from this document using
progenitor::generate_api!("openapi.json")withprogenitor = "=0.17.0". - Have
GET /itemreturn200,Content-Type: application/json,ETag: "v1"and the JSON string"current". When the request includesIf-None-Match: "v1", return304with the sameETagand an empty body. - 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
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di oxidecomputer/progenitor
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
oxidecomputer/progenitor#1345 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 58/100
oxidecomputer/progenitor#1457 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
oxidecomputer/progenitor#1444 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
oxidecomputer/progenitor#1382 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
oxidecomputer/progenitor#1318 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di oxidecomputer/progenitor
Issue simili
-
[Bug]: Add Data's question says "Link to the file" for a GeoPackage where small tables are copiedApertaunconfirmed possible issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
I maintainer di solito rispondono entro 1 giorno
-
documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
jerney-nexus/epikrise#364 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
Yeachan-Heo/gajae-code#8058 ·
I maintainer di solito rispondono entro 1 giorno
-
bug daemon
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno