Problem
Three low-severity REST compliance gaps identified during a full RESTful audit:
GET /players returns 404 Not Found when the collection is empty instead of 200 OK []
POST /players returns 201 Created without a Location header pointing to the new resource
POST /players returns 409 Conflict with no detail message, giving clients no programmatic context
Proposed Solution
Fix each gap independently:
- Return
200 OK with an empty list [] when no players exist — a 404 implies the resource itself is absent, not that it is empty
- Add a
Location response header on 201, e.g. response.headers["Location"] = f"/players/squadnumber/{player.squad_number}"
- Add
detail="A Player with this squad number already exists." to the 409 HTTPException
Suggested Approach
All changes are confined to routes/player_route.py:
- Empty collection (GET): change the 404 branch to return
JSONResponse(status_code=200, content=[]) or equivalent
- Location header (POST): append header to the response after successful creation
- 409 detail (POST): add
detail= kwarg to the existing raise HTTPException(...)
Acceptance Criteria
References
Problem
Three low-severity REST compliance gaps identified during a full RESTful audit:
GET /playersreturns404 Not Foundwhen the collection is empty instead of200 OK []POST /playersreturns201 Createdwithout aLocationheader pointing to the new resourcePOST /playersreturns409 Conflictwith nodetailmessage, giving clients no programmatic contextProposed Solution
Fix each gap independently:
200 OKwith an empty list[]when no players exist — a 404 implies the resource itself is absent, not that it is emptyLocationresponse header on 201, e.g.response.headers["Location"] = f"/players/squadnumber/{player.squad_number}"detail="A Player with this squad number already exists."to the 409HTTPExceptionSuggested Approach
All changes are confined to
routes/player_route.py:JSONResponse(status_code=200, content=[])or equivalentdetail=kwarg to the existingraise HTTPException(...)Acceptance Criteria
GET /playersreturns200 OKwith[]when no players exist (not404)POST /players201 response includes aLocationheader pointing to the created resourcePOST /players409 response includes a human-readabledetailmessageReferences
200 []on empty, not404