fix: suppress expected validation errors from error email notifications #228

Closed
opened 2026-04-06 11:18:31 -07:00 by hikari · 0 comments
Owner

Bug Report

Description

The error email notifications are being triggered by expected user-facing validation errors. Specifically, when a player attempts to challenge a boss without any adventurers ready, the API throws a validation error that propagates up through the middleware stack and ends up in the error emails.

This is expected behaviour — it is not a system failure, it is a player doing something invalid. It should not be treated as an unexpected error worthy of an email alert.

Example Email Content

challenge_boss Your party has no adventurers ready to fight
Error: Your party has no adventurers ready to fight
    at It (https://elysium.nhcarrigan.com/assets/index-B9lj9vRQ.js:162:426)
    at async Nm (https://elysium.nhcarrigan.com/assets/index-B9lj9vRQ.js:162:831)
    at async https://elysium.nhcarrigan.com/assets/index-B9lj9vRQ.js:207:20048
    at async v (https://elysium.nhcarrigan.com/assets/index-B9lj9vRQ.js:235:11794)

Error: challenge_boss Your party has no adventurers ready to fight
Error: Your party has no adventurers ready to fight
    at It (https://elysium.nhcarrigan.com/assets/index-B9lj9vRQ.js:162:426)
    at async Nm (https://elysium.nhcarrigan.com/assets/index-B9lj9vRQ.js:162:831)
    ...

Expected Behaviour

Validation errors (4xx-class errors representing invalid player actions) should not trigger error email notifications. Only unexpected server-side failures (5xx-class errors) warrant alerting.

Suggested Fix

In the error handling middleware (apps/api/src/routes/frontend.ts and/or the global error handler), differentiate between:

  • Validation/user errors — catch, log if desired, return appropriate HTTP 4xx response, do not email
  • Unexpected server errors — catch, log, return HTTP 500, do email

This likely involves checking whether the thrown error is an instance of a known validation error type (or checking the HTTP status code) before deciding whether to trigger the email notification.


This issue was created with help from Hikari~ 🌸

## Bug Report ### Description The error email notifications are being triggered by expected user-facing validation errors. Specifically, when a player attempts to challenge a boss without any adventurers ready, the API throws a validation error that propagates up through the middleware stack and ends up in the error emails. This is **expected behaviour** — it is not a system failure, it is a player doing something invalid. It should not be treated as an unexpected error worthy of an email alert. ### Example Email Content ``` challenge_boss Your party has no adventurers ready to fight Error: Your party has no adventurers ready to fight at It (https://elysium.nhcarrigan.com/assets/index-B9lj9vRQ.js:162:426) at async Nm (https://elysium.nhcarrigan.com/assets/index-B9lj9vRQ.js:162:831) at async https://elysium.nhcarrigan.com/assets/index-B9lj9vRQ.js:207:20048 at async v (https://elysium.nhcarrigan.com/assets/index-B9lj9vRQ.js:235:11794) Error: challenge_boss Your party has no adventurers ready to fight Error: Your party has no adventurers ready to fight at It (https://elysium.nhcarrigan.com/assets/index-B9lj9vRQ.js:162:426) at async Nm (https://elysium.nhcarrigan.com/assets/index-B9lj9vRQ.js:162:831) ... ``` ### Expected Behaviour Validation errors (4xx-class errors representing invalid player actions) should **not** trigger error email notifications. Only unexpected server-side failures (5xx-class errors) warrant alerting. ### Suggested Fix In the error handling middleware (`apps/api/src/routes/frontend.ts` and/or the global error handler), differentiate between: - **Validation/user errors** — catch, log if desired, return appropriate HTTP 4xx response, **do not email** - **Unexpected server errors** — catch, log, return HTTP 500, **do email** This likely involves checking whether the thrown error is an instance of a known validation error type (or checking the HTTP status code) before deciding whether to trigger the email notification. --- ✨ This issue was created with help from Hikari~ 🌸
naomi closed this issue 2026-04-06 18:17:04 -07:00
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: nhcarrigan/elysium#228