Repository navigation
400 for bad exam input, real staff hosts for visitors, teacher names only in class responses - #43
Conversation
…ames only in class responses Exam DTO parsers threw plain Errors, so bad input was a 500; they now return 400 INVALID_INPUT with the reason. A visitor's host must be an active staff account in the college (400 INVALID_HOST): an unknown id failed the insert with a 500, and a student host routed the approval to the wrong HOD. Class responses in assignments and the timetable, which students read, now carry the teacher's id and name only, not the employee code or account id.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6eb2bd8eb1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| - Once the exam has results, its papers are fixed (409 RESULTS_PUBLISHED). | ||
| - A paper can be removed only while its marks are a draft (409 MARKS_IN_REVIEW). Each removal writes an EXAM_PAPER_REMOVED audit entry with the number of marks deleted. | ||
| - GET /api/v1/exams/:id/results: ADMIN sees every student's result; an HOD sees their department's students; FACULTY see students actively enrolled in a section where they teach. | ||
| - Malformed exam input (names, dates, marks) returns 400 INVALID_INPUT with the reason, not a 500. |
There was a problem hiding this comment.
Reject malformed fields in exam updates
When an admin sends PUT /api/v1/exams/:id with an invalid startsOn or a blank name, parseUpdateExamDto silently drops that field, so the request can return success with no change or a partial update instead of the 400 promised here. Reject invalid supplied fields before documenting the 400 contract for exam input.
AGENTS.md reference: AGENTS.md:L78-L78
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in f37815a. parseUpdateExamDto now rejects any field that is sent but invalid (blank name, unreadable startsOn or endsOn, unknown status) with 400 INVALID_INPUT instead of dropping it, and refuses an end date before the start date.
An edit with a blank name, an unreadable date or an unknown status silently left that field out and reported success. Fields that are sent must now be valid (400 INVALID_INPUT), and the end date can't come before the start.
Three smaller items from the audit re-check: the exam DTO errors, part of H-10, and L-5.
Summary
Errors, so a bad date or a missing name came back as a 500. They now return 400INVALID_INPUTwith the reason, as the fee parsers do since Payments: settle only pending payments for their own order, pay only what is owed #34.PUT /exams/:id) silently dropped a field it couldn't use: a blank name, an unreadable date or an unknown status. It now rejects such a field with a 400, and an end date before the start date too.hostUserIdwas only checked to be a string. An unknown id failed the insert with a 500, and naming a student as host sent the approval to the wrong HOD, because the host decides which HOD approves. It must now be an active Admin, HOD or faculty account in the college, otherwise 400INVALID_HOST.Rules used
Validation
pnpm test(371 passed, 3 new; one extended for exam edits),pnpm lint,pnpm typecheck,pnpm build,git diff --check.id,firstNameandlastNamefor each teacher.INVALID_HOST.