Skip to content

Fix: Improve error handling and validation in reset password email process #729

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

shouryamanekar
Copy link

Issue Number: #728 [Enhancement: Add Robust Error Handling to /evershop/blob/main/packages/resend/api/resetPassword/[resetPassword]sendMail.js]


Summary

This PR enhances error handling and input validation in the [resetPassword]sendMail.js module. The goal is to prevent silent failures, improve logging, and provide clear user feedback when issues arise during the password reset email flow.


What is the current behavior?

  • Silent failures may occur when required fields (email, token) or configuration variables (RESEND_API_KEY, resend.from) are missing or invalid.
  • Errors in template reading, rendering, or email sending are not properly handled, potentially leading to no action taken or unclear responses.
  • There is insufficient logging for debugging and error tracking.

What is the new behavior?

  • Input validation ensures that email and token are present and valid before proceeding with the email flow.
  • Configuration checks for missing RESEND_API_KEY and resend.from provide better error handling.
  • Error handling for template rendering: If the template is invalid or fails to load, a fallback plain-text email is sent.
  • Error handling for the email send process: Any failure in sending the email is logged and results in an appropriate HTTP error response.
  • Improved logging captures meaningful context for all failure points, making debugging easier.
  • Structured HTTP responses with clear, user-friendly error messages and correct status codes (400 for client errors and 500 for server errors).

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes/features)
  • The code follows the existing project style and conventions
  • The PR has appropriate documentation (if applicable)
  • The changes are well-tested (manual testing in this case)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no API changes)
  • Build related changes
  • CI related changes
  • Other: Error-handling enhancement

Does this PR introduce a breaking change?

  • No

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