Unknown IDs/IRIs in custom endpoints give 500 instead of 404/400

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

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
Mezza giornata
Idoneità per principianti
66/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
php
Ambito
api, backend

Direzione di ricerca

Start in src/Controller/ScoreController.php (the setPaymentStatus route, where findOneById() can return null) and src/Controller/UserController.php (the updatePasswordAdmin route, where targetUser is resolved). The /transfer endpoint's uncaught ItemNotFoundException is also in scope. Run tests/Api/ScoreTest.php and tests/Api/UserManagementTest.php, where the current 500 behaviour is pinned under NOTE: current behaviour. Done means unknown ids return 404, unresolvable IRIs in the body return 400 with a message, and those pinned assertions are updated to match.

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

Descrizione

Backend bug severity: low

Problem

Custom endpoints don't handle references that don't exist:

  • POST /transfer with an unknown target IRI: an uncaught ItemNotFoundException gives a 500.
  • POST /updatePasswordAdmin with an unknown targetUser IRI: 500.
  • POST /api/scores/{id}/setPaymentStatus with an unknown id: findOneById() returns null and a method is called on it, so an Error gives a 500.

Expected

Unknown ids → 404, unresolvable IRIs in the body → 400 with a message.

Where

src/Controller/ScoreController.php, src/Controller/UserController.php.
Pinned in tests/Api/ScoreTest.php (around lines 105 and 305) and tests/Api/UserManagementTest.php (around line 278).


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.