Skip to content

[BUG] Correct Error Code for Invalid Recipient Email Validation#1796

Open
zealot-zew wants to merge 1 commit into
mosip:masterfrom
zealot-zew:fix/recipient-validation-error-code
Open

[BUG] Correct Error Code for Invalid Recipient Email Validation#1796
zealot-zew wants to merge 1 commit into
mosip:masterfrom
zealot-zew:fix/recipient-validation-error-code

Conversation

@zealot-zew
Copy link
Copy Markdown

@zealot-zew zealot-zew commented Apr 25, 2026

Summary

This PR fixes a bug in EmailNotificationUtils.java where an invalid recipient email address (mailTo) triggered a sender-related error code (KER-NOE-007) instead of the appropriate receiver-related error code (KER-NOE-001).

Problem

In the tos validation loop, the catch block was hardcoded to return SENDER_ADDRESS_NOT_FOUND. This caused API consumers to receive misleading feedback ("From must be valid") when the actual issue was an invalid "To" address.

Changes

File: EmailNotificationUtils.java

Update: Replaced SENDER_ADDRESS_NOT_FOUND with RECEIVER_ADDRESS_NOT_FOUND within the tos.forEach validation block.

Impact

Accuracy: API error responses now correctly identify the recipient as the source of the validation failure.
UX: Developers and consumers will no longer be misled by "Sender" errors when troubleshooting recipient list issues.

Summary by CodeRabbit

  • Bug Fixes
    • Corrected error reporting for invalid recipient email addresses to display accurate error codes instead of misleading sender-related messages.

When validating recipient (mailTo) email addresses in
EmailNotificationUtils.validateMailArguments(), the error reported
SENDER_ADDRESS_NOT_FOUND (KER-NOE-007) instead of
RECEIVER_ADDRESS_NOT_FOUND (KER-NOE-001).

This caused misleading error messages: users were told
'From must be valid' when the actual problem was an invalid
recipient address.

Changed to use RECEIVER_ADDRESS_NOT_FOUND for the mailTo
validation loop to correctly report KER-NOE-001.

Signed-off-by: hari <hari@users.noreply.github.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 25, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e0eeb9d9-5c15-4c86-a708-2fb3a4e0daea

📥 Commits

Reviewing files that changed from the base of the PR and between c30080f and 7c72733.

📒 Files selected for processing (1)
  • kernel/kernel-notification-service/src/main/java/io/mosip/kernel/emailnotification/util/EmailNotificationUtils.java

Walkthrough

The email notification validation now reports the correct error code RECEIVER_ADDRESS_NOT_FOUND instead of SENDER_ADDRESS_NOT_FOUND when recipient email validation fails. The validation logic and error handling flow remain unchanged.

Changes

Cohort / File(s) Summary
Email Validation Error Code
kernel/kernel-notification-service/src/main/java/io/mosip/kernel/emailnotification/util/EmailNotificationUtils.java
Updated recipient email validation to report RECEIVER_ADDRESS_NOT_FOUND instead of SENDER_ADDRESS_NOT_FOUND for failed mailTo validation.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

🐰 A fix most neat, both small and fine,
Wrong error codes now realign,
Receivers rejoice, no more confusion,
This humble change ends all illusion! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: correcting an error code for recipient email validation from the incorrect sender-related code to the correct receiver-related code.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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