Missing required fields give 500 instead of 400

Aperta
#67 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
68/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
php
Ambito
api, backend

Direzione di ricerca

Start with the three controllers named in the issue: src/Controller/CycleController.php, UserController.php and ScoreController.php, looking at where each reads request fields without checking them. The pinned behaviour is in tests/Api/CycleTest.php (around line 169), tests/Api/UserManagementTest.php (around line 107) and tests/Api/ScoreTest.php (around line 93), marked NOTE: current behaviour. Done means each missing required field returns 400 naming the missing fields, and those tests are updated to assert it.

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

Descrizione

Backend bug severity: low

Problem

Several custom endpoints read request fields without checking them, so a missing field ends in "Undefined array key" and a 500:

  • POST /api/cycles without toDate
  • POST /api/users without lastname
  • POST /api/scores/{id}/setPaymentStatus without newPaymentStatus

Only unknown fields are rejected today.

Expected

400 with the names of the missing fields (validate the payload, e.g. with a DTO + Validator or MapRequestPayload).

Where

src/Controller/CycleController.php, UserController.php, ScoreController.php.
Pinned in tests/Api/CycleTest.php (around line 169), tests/Api/UserManagementTest.php (around line 107) and tests/Api/ScoreTest.php (around line 93).


Found by the API test suite added for #57 (branch feature/57-symfony-7.4); the behaviour is the same before and after the Symfony 7.4 upgrade. The current behaviour is pinned in the test named above (marked NOTE: current behaviour), so update that test together with the fix.

Lingua principale
PHP
Stelle
1
Fork
0
Merge medio
7h 58m
PR unite (30g)
3

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 RunningJoke/allipunkte

Tutte le issue di RunningJoke/allipunkte

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.