Dashboard: a successful response whose JSON does not parse is treated as an empty success

Aperta Adatta ai principianti
#1,039 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à
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
88/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
typescript
Ambito
frontend

Direzione di ricerca

Inizia leggendo frontend/src/services/api.ts intorno a readSuccessBody e al ramo di errore non JSON immediatamente sopra. Conferma che le risposte 204/205 vuote siano gestite separatamente, poi modifica il percorso del JSON malformato per far generare lo stesso tipo di ApiError specifico del percorso. Verifica con i test pertinenti del servizio frontend, inclusa una risposta JSON 2xx con body troncato o non valido.

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

Descrizione

bug post-launch

readSuccessBody in frontend/src/services/api.ts (lines ~370-375) returns undefined when a 2xx response with a JSON content type has a body that does not parse:

try {
  return (await response.json()) as T;
} catch {
  return undefined as T;
}

So a truncated or malformed successful body is treated as a successful empty result. The caller then shows success, or fails later on a property of undefined with a message that does not say what went wrong. Empty 204/205 responses are already handled before this point and are not affected.

Expected: a body that the content type says is JSON but that does not parse raises an ApiError naming the path (as the non-JSON branch above already does), so the page shows a clear error. Found in a code review (2026-10-06); no user report.

Lingua principale
Python
Stelle
0
Fork
4
Merge medio
5h 36m
PR unite (30g)
509

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 Controlvar/controlvar

Tutte le issue di Controlvar/controlvar

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.