Return 404 when looking up an unknown lecture
LectureController.find calls findOne and then reads lecture.length. With no match, lecture is null and that access reaches the 500 error handler. The frontend builds lecture links from slugs; an unknown slug needs a predictable not-found response.
- Estimated size
- S · 1–3 hours
- Skills
- JavaScript · Express · Mongoose
Files and evidence
- YagoLagrottiBracco/congresso-api/src/app/controllers/LectureController.jsTarget file ·
f31b0d0f31cf· L38–L56 - YagoLagrottiBracco/congresso-front/src/templates/organisms/molecules/LecturyCard.jsxContext ·
8abed2d12d20· L6–L15
Step-by-step acceptance criteria
- Add a regression for GET /lecturies/find/unknown-slug with findOne returning null.
- Replace the length access with a missing-document check and return 404 using the existing sendResponse format.
- Verify a valid document still returns 200 with its data and a database rejection still returns 500.
- Document the three cases and the test command in the PR; use local fixtures without relying on the production database.