Generated client treats a declared 304 Not Modified as UnexpectedResponse

オープン
#1,462 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@jjant がすでに取り組んでいます。

2026年11月19日 から。

  • #1463 @jjant による — オープン

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
25/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
openapi, rust

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Rust
スター
1k
フォーク
142
平均マージ
19時間 13分
マージ済み PR(30日)
16

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

oxidecomputer/progenitor のほかの issue

oxidecomputer/progenitor の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。