Rust client (and the hindsight CLI) fail on enum values added after their release

Aperta
#6,912 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à
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
57/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
python, rust
Ambito
backend, cli

Direzione di ricerca

Start with hindsight-clients/rust/build.rs, especially dedupe_inline_enum_titles and the regex replacements, then inspect the generated client enums and how hindsight-cli/Cargo.toml uses the client. Check how unknown enum values and new anyOf tag-group shapes deserialize. Done means responses containing values added after the client release can be parsed without a serde unknown-variant error.

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

Descrizione

core

What happens

The Rust client (hindsight-clients/rust, generated by progenitor/typify in build.rs) turns every OpenAPI enum into a closed Rust enum with no fallback variant, for example:

pub enum Budget {
    #[serde(rename = "low")] Low,
    #[serde(rename = "mid")] Mid,
    #[serde(rename = "high")] High,
}

Deserializing a value the server added later fails, so the whole response fails to parse. The hindsight CLI is built on this client (hindsight-cli/Cargo.toml), so a published CLI breaks each time the server adds an enum value (e.g. grounding_gone from #6861) in a response the CLI reads. The same applies to a new tag-group shape in an anyOf.

This is the Rust half of #6862. The Python and Go clients are fixed in #6911.

How to see it

  1. Build the CLI from a commit before an enum value was added.
  2. Against a current server, read a response that carries the new value (e.g. a mental model whose refresh trace has mode_fallback_reason: "grounding_gone").
  3. The CLI fails with a serde "unknown variant" error.

What should happen

An unknown value should be accepted, e.g. a #[serde(other)] Unknown variant (or an Unknown(String) variant that keeps the value), instead of failing the whole response.

Where

  • hindsight-clients/rust/build.rs: it already rewrites the spec and the generated code (dedupe_inline_enum_titles, regex replacements), so it could add a catch-all variant to each generated enum.
Lingua principale
Python
Stelle
45.2k
Fork
5.9k
Merge medio
6h 18m
PR unite (30g)
354

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 vectorize-io/hindsight

Tutte le issue di vectorize-io/hindsight

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.