generated from nhcarrigan/template
fix: suppress expected validation errors from error email notifications #228
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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
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.tsand/or the global error handler), differentiate between: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~ 🌸