Skip to content

400 for bad exam input, real staff hosts for visitors, teacher names only in class responses - #43

Merged
anishmehta24 merged 2 commits into
mainfrom
fix/small-hardening
Nov 18, 2026
Merged

anishmehta24 merged 2 commits into
mainfrom
fix/small-hardening

Conversation

@anishmehta24

@anishmehta24 anishmehta24 commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Three smaller items from the audit re-check: the exam DTO errors, part of H-10, and L-5.

Summary

  • Bad exam input is a 400. The exam DTO parsers threw plain Errors, so a bad date or a missing name came back as a 500. They now return 400 INVALID_INPUT with the reason, as the fee parsers do since Payments: settle only pending payments for their own order, pay only what is owed #34.
    • From review: an exam edit (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.
  • A visitor's host must be real staff. hostUserId was 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 400 INVALID_HOST.
  • Students see a teacher's name, nothing more. Assignment and timetable responses included the whole faculty row for each class: employee code, account id, department id and designation. Students read these responses, so classes now carry the teacher's id and name only. The web only ever showed the name.

Rules used

  1. A host can be any active staff member (Admin, HOD or faculty), matching who can approve or receive visitors.
  2. Students can still register visitors, as the Visitors page offers them, now only with a staff host or none.

Validation

  • pnpm test (371 passed, 3 new; one extended for exam edits), pnpm lint, pnpm typecheck, pnpm build, git diff --check.
  • Locally:
    • The student's timetable and assignments listed only id, firstName and lastName for each teacher.
    • Registering a visitor with the student as host, or with an unknown id, returned INVALID_HOST.
    • Creating an exam with unreadable dates returned 400 (it was a 500).

…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.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-18T10:40:12.162466Z 6eb2bd8 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread docs/api.md
- 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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@anishmehta24
anishmehta24 merged commit 526774b into main Nov 18, 2026
@anishmehta24
anishmehta24 deleted the fix/small-hardening branch November 18, 2026 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant