#347 Validate Position Status, Window, And Deletion In Reopen - #409
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
b-at-neu
left a comment
There was a problem hiding this comment.
Code Review — Cycle 1 · needs revision
3 open — 1 🔴 Critical, 1 🟡 Low, 1 ⚪ Nit
R1-C1 🔴 Critical — the Vercel check is failing: https://vercel.com/sga-operational-affairs-projects/aplio/5YeWuvmRRZSd3wCHKhJnr124XXWa. Fix: resolve the failing deployment before merge.
R1-L1 🟡 Low (preexisting) — submitApplication (
aplio/prisma/actions/applications.ts
Line 265 in 0e0592b
prisma.$transaction and never checks position.deletedAt, unlike the now-hardened reopenApplication this PR ships. Fix: file a follow-up to bring submitApplication to the same bar (wrap in $transaction, add the deletedAt check).
Revision — Cycle 1fixed R1-N1 · skipped R1-C1 · 8c08784 R1-C1: investigated — this PR only touches follow-up: R1-L1 (preexisting) — |
b-at-neu
left a comment
There was a problem hiding this comment.
Code Review — Cycle 2 · needs revision
2 open — 1 🔴 Critical, 1 🟡 Low
R2-C1 🔴 Critical — the Vercel required check is still failing: https://vercel.com/sga-operational-affairs-projects/aplio/ASxDszkxrYTKuVmUXHtwD4D1n7Xt. Diagnosed as a Neon preview-branch quota issue unrelated to this diff (now tracked in #412), but the check itself remains red and blocks merge. Fix: resolve the branch quota / land #412, or retry once capacity frees up.
R2-L1 🟡 Low (preexisting) — submitApplication (
aplio/prisma/actions/applications.ts
Lines 265 to 266 in 8c08784
prisma.$transaction and never checks position.deletedAt, unlike the now-hardened reopenApplication. Fix: file the follow-up ticket to bring it to parity (or fix it in this PR).
8c08784 to
040fd19
Compare
Revision — Cycle 2skipped R2-C1, R2-L1 · 040fd19 R2-C1: rebased onto latest R2-L1: preexisting ( |
b-at-neu
left a comment
There was a problem hiding this comment.
Code Review — Cycle 3 · needs revision
1 open — 1 🔴 Critical
R3-C1 🔴 Critical — the Vercel check is still failing: https://vercel.com/sga-operational-affairs-projects/aplio/F7MpMPuvb12kjtqkFhSgiGGMQbMj. Same Neon preview-branch quota issue diagnosed in cycles 1-2 (tracked in #412), unrelated to this diff, but it remains red and blocks merge. Fix: land #412 or retry once branch capacity frees up.
reopenApplication only checked ownership and source status, so a withdrawn application against a deleted, closed, or draft position could be reopened straight into the review queue. It now re-reads the position and required answers inside a transaction, applying the same gates submitApplication uses, before writing the applied status. Extracted findMissingRequiredAnswers so submit and reopen share one required-answer check and can't drift. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Reword the reopenApplication comment (R1-N1): it previously claimed submitApplication uses the same pattern, but only reopenApplication runs inside a $transaction. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
040fd19 to
a71d495
Compare
b-at-neu
left a comment
There was a problem hiding this comment.
Code Review — Cycle 4 · approved
0 open — clean
Closes #347
Summary
reopenApplicationonly checked that the caller owned the application and that its status waswithdrawn— it performed no check on the position at all, so a withdrawn application against a soft-deleted, draft, closed, or out-of-window position could be reopened straight into the review queue.Changes
prisma/actions/applications.tsfindMissingRequiredAnswershelper (position + required-answer check logic) shared bysubmitApplicationand the rewrittenreopenApplication, so the two gates can't drift.submitApplicationto call the helper — same order, same messages, no behavior change.reopenApplicationto run insideprisma.$transaction: re-reads the application with its position and answers (ownership + source status folded into thewhere), then gates in order — not found/not withdrawn → position soft-deleted → not accepting (draft/closed/before-open/after-close) → missing required global answers → missing required position answers — before writingappliedvia a caller-scopedupdateMany.submittedAtis left untouched.No schema change, no UI changes — the existing confirm dialog already toasts a returned
{ error }.Testing plan
Set up via the manager UI (create/edit/delete positions) and the applicant UI (apply → withdraw). For each case, press Re-open on
/my-applicationsand confirm./applications.closesAtset to yesterday, status still open → same message; and same-dayclosesAt(today) still succeeds (inclusive end-of-day).opensAtset to tomorrow → same message.npm run prettier:check·npm run eslint:check·npm run tsc:checkAutomated checks
npm run prettier:check— passnpm run eslint:check— passnpm run tsc:check— passNotes
prisma/actions/applications.ts(createOrUpdateApplicationAnswer/submitApplicationstatus gating). This PR only refactorssubmitApplication's required-answer block into a shared helper and leaves its status scoping alone — expect a rebase touchpoint insubmitApplicationif Gate Application Answer Writes and Submission on Application Status #345 lands first, resolvable by keeping both sides.getMyApplicationsdoesn't select position state). Refusal is server-side with a clear message; hiding/relabelling the button belongs to the Resubmit rework tracked separately, not this fix.