Skip to content

Fix/application email failure bug - #121

Open
sriya-veluri wants to merge 5 commits into
candiedoperation:masterfrom
sriya-veluri:fix/application-email-failure-bug
Open

sriya-veluri wants to merge 5 commits into
candiedoperation:masterfrom
sriya-veluri:fix/application-email-failure-bug

Conversation

@sriya-veluri

@sriya-veluri sriya-veluri commented Nov 4, 2026 •

Copy link
Copy Markdown

Summary
Persist email delivery status and the original message request when an applicant is moved to Interview or Rejected.
Return delivery status and error details to the recruitment dashboard.
Add a retry action that resends the saved message without repeating the stage change.
Require confirmation before retrying an email whose delivery outcome is uncertain.

Behavior
Email delivery status is recorded as pending, accepted, failed, or uncertain. Clear SMTP acceptance/rejection and known pre-delivery failures are classified from the transport result; ambiguous send errors such as timeouts are marked uncertain to avoid implying the email definitely was not delivered.

The retry endpoint only accepts failed or uncertain deliveries. Uncertain retries require confirmation because the first message may already have reached the SMTP server. Retries reuse the saved email request and do not add another stage-history entry.

This change covers the existing Interview and Rejected stage emails. It does not modify the Hired flow, invite creation, or stage transitions.

Validation
./nx run pplserver:build --excludeTaskDependencies — passed
./nx run pplserver:test-integration --excludeTaskDependencies — passed (16 tests)
./nx run pplui:build --excludeTaskDependencies — passed; emitted existing warnings about a duplicate pk, a Lexical export, and bundle size
git diff --check — passed
Mailpit SMTP smoke test — passed; the portal EmailClient sent a synthetic .invalid recipient message and Mailpit confirmed it was captured
The integration tests cover persisted status, SMTP rejection, timeout/uncertain handling, confirmation, and retry without repeating the stage change.

Closes #101

@IanCou

IanCou commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator

The status model and confirm-before-retry flow look good. Two bugs to fix in ATSController.ts before merge:

Late send overwrites a newer result (~line 2110). The save() after the SMTP call lets a slow older attempt overwrite a newer one. I reproduced a 550 rejection turning into accepted. Fix: give each attempt an id and write the result with a conditional updateOne on that id and status: "pending".
Stuck PENDING (~lines 1419-1426). If the server dies mid-send, retry returns 409 forever. Fix: treat old PENDING (say over 5 minutes, from lastAttemptAt) as uncertain.

Please add a test for each. Also, master now has #81’s TanStack Query rewrite of the recruitment screen, so the UI part needs porting. I have a merged version if you want it.

This branch has not been deployed

No deployments
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.

[BUG] Failed Email Sends Not Shown to Leads

2 participants