Skip to content

fix: enforce email or webhook_url on notification preferences - #499

Open
Akintobidavid wants to merge 2 commits into
Heliobond:mainfrom
Akintobidavid:fix/issue-338-notification-service-put-preferences-address
Open

fix: enforce email or webhook_url on notification preferences#499
Akintobidavid wants to merge 2 commits into
Heliobond:mainfrom
Akintobidavid:fix/issue-338-notification-service-put-preferences-address

Conversation

@Akintobidavid

Copy link
Copy Markdown

Overview

This PR fixes the notification-service validation gap in PUT /preferences/:address. The handler now checks the resulting preference and returns 400 when neither email nor webhook_url is set. Empty bodies and bodies containing only { "enabled": true } no longer silently create preferences that cannot notify anyone.

Related Issue

Changes

🔔 Notification Preference Validation

  • [MODIFY] notification-service/src/api.ts
    • Validate that the resulting preference has at least one notification channel.
    • Reject with 400 when both email and webhook_url are absent, null, or empty string.
    • Return a clear error body: { "error": "At least one of email or webhook_url must be provided." }
    • Preserve existing preferences that already have email or webhook_url set when an update omits both fields.
    • Allow updates such as { "enabled": false } on a preference that already has one channel configured.

Verification Results

npm test -- notification-service/src/api.test.ts
✅ 12/12 passed

Manual API checks:
✅ PUT /preferences/:address with {} → 400
✅ PUT /preferences/:address with { "enabled": true } → 400
✅ PUT /preferences/:address with { "email": "[email protected]" } → 200
✅ PUT /preferences/:address with { "webhook_url": "https://example.com/hook" } → 200
✅ PUT existing preference with email set, body { "enabled": false } → 200
Acceptance Criteria Status
PUT /preferences/:address with neither email nor webhook_url (and no pre-existing preference) returns 400 with a clear error message ✅ Verified with empty body and enabled-only body
Updating an existing preference that already has one channel set, without supplying either field again, is still allowed ✅ Verified with existing email preference + { "enabled": false }

Closes #338

@drips-wave

drips-wave Bot commented Aug 31, 2026

Copy link
Copy Markdown

@Akintobidavid Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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.

notification-service: PUT /preferences/:address doesn't enforce that at least one of email/webhook_url is provided

1 participant