fix: tolerate stale trigger_type values in settings response#261
Merged
LeonardoVieira1630 merged 1 commit intoMay 27, 2026
Conversation
SettingsService.getUserPreferences now filters out preference rows whose trigger_type is not in the current NotificationTypeId enum, so legacy or manually inserted values in user_notification_preferences cannot break the GET /users/by-channel/:channel/:channelUserId/notification-preferences response. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
brunod-e
approved these changes
May 27, 2026
f86eb2a
into
fix/offchain-notifications-sdk-1.2.0
7 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SettingsService.getUserPreferencesnow dropsuser_notification_preferencesrows whosetrigger_typeisn't in the currentNotificationTypeIdenum. Legacy or hand-inserted DB values can no longer break the API response.Why this matters
The
GET /users/by-channel/:channel/:channelUserId/notification-preferencesresponse is validated by Fastify againstz.nativeEnum(NotificationTypeId)(apps/subscription-server/src/schemas/settings.schema.ts). The DB columnuser_notification_preferences.trigger_typeis juststring(100)— there is no enum constraint at the DB level — so any single row with a value outside the current enum makes the whole response fail withFST_ERR_RESPONSE_SERIALIZATION→ 500.This happened in prod because the enum was renamed in
870b35a(offchain-voting-reminder-75→offchain-voting-reminder-50). Anyone who saved preferences before the rename still has the old value in the DB, and any GET for that user blows up with a 500. Downstream effect:error loading notification settings—subscription-serverreturns 500 withResponseSerializationError.The write side is untouched and stays strict (
z.nativeEnumin the body schema), so we never persist garbage. We only relax the read path, which already had to deal with whatever the DB contained. The consumers (base-settings.service.ts) were already defensively ignoring unknown trigger types on their side, so the filter at the service boundary is consistent with how the data is consumed.This is also resilient to future renames or manual inserts — no migration needed, no constraint to add, no risk of a single bad row breaking the UI for a user.
Test plan
pnpm vitest runinapps/subscription-server— 30/30 passing, includes new casedrops rows whose trigger_type is no longer in the current enumpnpm tsc --noEmitinapps/subscription-server— clean/anticapture→ settings / list DAOs works for users with legacyoffchain-voting-reminder-75rows🤖 Generated with Claude Code